Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active August 23, 2020 06:42
Show Gist options
  • Save weshouman/35b0350889937905c2768ab9196ca2c2 to your computer and use it in GitHub Desktop.
Save weshouman/35b0350889937905c2768ab9196ca2c2 to your computer and use it in GitHub Desktop.
AWK hints

Following are some hints

  • There are many flavors for awk, mawkminimal&default, gawkfeature-full & nawknew-implementation
  • For a technical comparison between mawk and gawk follow this google discussion
  • MAWK was slow, follow this guide. But the recent version 1.3.4 seems to fix that
  • AWKPATH is only available in gawk. nawk may have it too. But the default one mawk only uses the -f notation, it doesn't even havet the @inlcude statement, thus one can't nest the files, without creating a wrapper application, in a conf/lib like directory structure.

To get the uid and gid from the cli use

# The -F field separator accepts regular expressions
# which allows the following usage
echo $(id | awk -F'[ =(]' '{print $2}'):$(id | awk -F'[ =(]' '{print $5}')
# example output is 1000:1000 or 0:0 for the root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment