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
If you're using bash:
diff file <(grep -E '^[0-9]+$' file)
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 to diff
causes it to read its standard input. The <(COMMAND)
syntax becomes more useful when both arguments to diff
are command output, such as:
diff <(this_command) <(that_command)