Quantcast
Channel: How to hide command output, then run another command - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2

Answer by terdon for How to hide command output, then run another command

$
0
0

You can use ; instead of || or &&. The ; just separates commands and the second command doesn't depend on the first at all:

$ false; echo yeahyeah$ true; echo yeahyeah$ false || echo yeahyeah$ false && echo yeah$ true && echo yeahyeah$ true || echo yeah$ 

Also, using ( command ) means that command will run in its own subshell. You can use { command; } if you want to group commands without subshells, but here you don't need any of that. You can just do:

aaa &>/dev/null ; bbb

That will first run aaa, redirecting both output and error to /dev/null, and then it will run bbb. Note that you didn't need the subshell for && or || either. You could just have done aaa >/dev/null && bbb and it would have done the same thing.

Finally, if all you want is to ignore the error message, you can redirect standard error only, no need to also redirect output:

aaa 2>/dev/null

And here are some useful references for the things I mentioned:


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>