Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8.  
  9. $ cat file1
  10. 1 2 3 4 5 6 7
  11. $ cat file2
  12. 1
  13. 2
  14. 4
  15. 3
  16. 5
  17. 6
  18. 7
  19. $ diff <(echo $(< file1)) <(echo $(< file2))
  20. 1c1
  21. < 1 2 3 4 5 6 7
  22. ---
  23. > 1 2 4 3 5 6 7
  24.  
  25. < file # Equivalent to "cat file", but slightly faster since the shell doesn't
  26. # have to fork a new process.
  27.  
  28. $(< file) # Capture the output of the "< file" command. Can also be written
  29. # with backticks, as in `< file`.
  30.  
  31. echo $(< file) # Echo each word from the file. This will have the side effect of
  32. # collapsing all of the whitespace.
  33.  
  34. <(echo $(< file)) # An advanced way of piping the output of one command to another.
  35. # The shell opens an unused file descriptor (say fd 42) and pipes
  36. # the echo command to it. Then it passes the filename /dev/fd/42 to
  37. # diff. The result is that you can pipe two different echo commands
  38. # to diff.
  39.  
  40. $ diff -u <(printf '%sn' $(< file1)) <(printf '%sn' $(< file2))
  41. --- /dev/fd/63 2012-09-10 23:55:30.000000000 -0400
  42. +++ file2 2012-09-10 23:47:24.000000000 -0400
  43. @@ -1,7 +1,7 @@
  44. 1
  45. 2
  46. -3
  47. 4
  48. +3
  49. 5
  50. 6
  51. 7
  52.  
  53. awk '{printf"%s ", $0}' file2
  54.  
  55. awk '{for (i=1;i<=NF;i++) printf("%sn", $i)}' file1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement