When I use >> nonexistent/file.log
. Bash gives me back "No such file or directory".
How can I make a one liner that redirects the STDOUT/STDERR to a log file, even if it doesn't exist? If it doesn't exist, it must create the necessary folders and files.
Using install
:
command | install -D /dev/stdin nonexistent/file.log
or use
mkdir nonexistent
first.