Advertisement
thesuhu

Awk Command

Oct 17th, 2020 (edited)
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.64 KB | None | 0 0
  1. # menampilkan kolom 3 dan 4
  2. awk '{print $3 "\t" $4}' marks.txt
  3.  
  4. # prints all the lines that match pattern.
  5. awk '/a/ print:$0}' test.txt
  6. awk '/a/' tag.txt
  7.  
  8. # prints the third and fourth field when a pattern match succeeds.
  9. awk '/a/ {print $3 "\t" $4}' test.txt
  10.  
  11. # prints the fourth column followed by the third column.
  12. awk '/a/ {print $4 "\t" $3}' test.txt
  13.  
  14. # print the number of lines for which a pattern match succeeded.
  15. awk '/a/{++cnt} END {print "Count = ", cnt}' test.txt
  16.  
  17. # print only those lines that contain more than 18 characters.
  18. awk 'length($0) > 18' test.txt
  19.  
  20. # replace ' (single quote)
  21. awk '{gsub( "[:'\'']","" ); print}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement