Guest User

Untitled

a guest
Jan 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. ~$> cat awktest1.txt
  2. 111 112 113 114|121 122 123 124|131 132 133 134|141 142 143 144
  3. ~$> cat awktest2.txt
  4. 211 212 213 214
  5.  
  6. 221 222 223 224
  7.  
  8. 231 232 233 234
  9.  
  10. 241 242 243 244
  11.  
  12. #! /usr/bin/awk -f
  13.  
  14. # awktest.awk file1 file2
  15. # cant swap RS between files
  16.  
  17. BEGIN { RS="|" }
  18.  
  19. NR>ONR && ONR==1 { RS="" }
  20. { print $1 "." $2 "." $3 "." $4 }
  21.  
  22. # will work with with, but this is GNU only.
  23. # ENDFILE { RS="" }
  24. END { print "nfinal $0: n" $0 }
  25.  
  26. ~$>./awktest.awk awktest1.txt awktest2.txt
  27. 111.112.113.114
  28. 121.122.123.124
  29. 131.132.133.134
  30. 141.142.143.144
  31. 211.212.213.214
  32.  
  33. final $0:
  34. 211 212 213 214
  35.  
  36. 221 222 223 224
  37.  
  38. 231 232 233 234
  39.  
  40. 241 242 243 244
Add Comment
Please, Sign In to add comment