将lz4的输出重定向到/dev/null。

huangapple go评论68阅读模式
英文:

lz4 redirect output to /dev/null

问题

以下是您要翻译的内容:

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

英文:

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

答案1

得分: 1

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"
英文:

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"

huangapple
  • 本文由 发表于 2023年3月7日 17:09:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75659935.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定