Reputation:
For example:
cat a.txt
1 2
1 6
{ cat $HOME/SANITY/file.txt | grep 1 >> $HOME/SANITY/new.txt } > /dev/null
cut -d' ' -f2
Now i don't want the results to be shown when running the script with this code.
Upvotes: 7
Views: 9360
Reputation: 681
Simply use in your case :
grep 1 "$HOME/SANITY/file.txt" >> "$HOME/SANITY/new.txt"
And for general purpose :
command_foo_bar > /dev/null # or any other non special file
Upvotes: 1
Reputation: 5232
You can redirect the output. if you only use your_command > /dev/null
only stdout
will be redirected. If you want to remove the output of stderr
as well, redirect stderr
to stdout
and stdout
to /dev/null
using:
your_command > /dev/null 2>&1
2>&1
will move stderr
to the file descriptor of stdout
.
Upvotes: 11