Created
January 12, 2016 09:28
-
-
Save jvanja/2893df5c38b86f31049c to your computer and use it in GitHub Desktop.
Useful awk examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#searches for 'search_term' and prints all columns | |
awk '/search_term/' file.txt | |
#searches for 'search_term' and prints columns 1 and 4 separated with tab (the first column is index 1) | |
awk '/search_term/ {print $1 "\t" $4}' file.txt | |
#searches for 'search_term' and prints the number of occurances | |
awk '/search_term/{++cnt} END {print "Count = ", cnt}' file.txt | |
#print lines having more than 18 characters | |
awk 'length($0) > 18' file.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment