Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- $ cat file1
- 1 2 3 4 5 6 7
- $ cat file2
- 1
- 2
- 4
- 3
- 5
- 6
- 7
- $ diff <(echo $(< file1)) <(echo $(< file2))
- 1c1
- < 1 2 3 4 5 6 7
- ---
- > 1 2 4 3 5 6 7
- < file # Equivalent to "cat file", but slightly faster since the shell doesn't
- # have to fork a new process.
- $(< file) # Capture the output of the "< file" command. Can also be written
- # with backticks, as in `< file`.
- echo $(< file) # Echo each word from the file. This will have the side effect of
- # collapsing all of the whitespace.
- <(echo $(< file)) # An advanced way of piping the output of one command to another.
- # The shell opens an unused file descriptor (say fd 42) and pipes
- # the echo command to it. Then it passes the filename /dev/fd/42 to
- # diff. The result is that you can pipe two different echo commands
- # to diff.
- $ diff -u <(printf '%sn' $(< file1)) <(printf '%sn' $(< file2))
- --- /dev/fd/63 2012-09-10 23:55:30.000000000 -0400
- +++ file2 2012-09-10 23:47:24.000000000 -0400
- @@ -1,7 +1,7 @@
- 1
- 2
- -3
- 4
- +3
- 5
- 6
- 7
- awk '{printf"%s ", $0}' file2
- awk '{for (i=1;i<=NF;i++) printf("%sn", $i)}' file1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement