I am having trouble with this simple task:
cat file | grep -E ^[0-9]+$ > file_grep
diff file file_grep
Problem is, I want to do this without file_grep
I have tried:
diff file `cat file | grep -E ^[0-9]+$`
and
diff file "`cat file | grep -E ^[0-9]+$`"
and a few other combinations 🙂 but I can’t get it to work.
I always get an error, when the diff gets extra argument which is content of file filtered by grep.
Something similar always worked for me, when I wanted to echo command outputs from within a script like this (using backtick escapes):
echo `ls`
Thanks
If you’re using bash:
The
<(COMMAND)sequence expands to the name of a pseudo-file (such as/dev/fd/63) from which you can read the output of the command.But for this particular case, ruakh’s solution is simpler. It takes advantage of the fact that
-as an argument todiffcauses it to read its standard input. The<(COMMAND)syntax becomes more useful when both arguments todiffare command output, such as: