Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# How many characters per line?
$ awk '{ print length($0) }'
# How many words per line? Add -F for separator
awk '{ print NF }'
# How do I see a substring? Example, 4 characters starting at position 2
$ awk '{ print substr($0, 2, 4) }'
# Alternative to the above, use cut:
$ cut -c2-4
# Where is my substring?
$ awk '{ print index($0, "string") }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.