I have the following command in my bash script and want to redirect the output to /dev/null but it is not working. What is the right way to achieve this?
tar cvf - -C / $SOURCE_DIR | lz4 --best - $ARCHIVE > /dev/null
Edit:
Example output (I'm creating an archive of the /home/philip/test
folder):
home/philip/test/
home/philip/test/test.txt
I want the above output to be redirected to /dev/null.
--$SOURCE_DIR is the folder I'm archiving. Ex: home/philip/test
--$ARCHIVE is the destination path where the archive is saved. Ex: /home/philip/temp.tar.lz4
Both commands might also errput messages when a problem occurs, so I don't recommend muting their stderr completely; I would just rework the command line in a way that limits their stderr to warnings/errors only:
tar cf - "$SOURCE_DIR" | lz4 -9 - > "$ARCHIVE"