Awk

From miki
Jump to navigation Jump to search

References

Awk Program Examples

ps al | awk '{print $2}'                                # Print second field of ps output
find /proc -type l | awk -F"/" '{print $3}'             # Print second folder name (i.e. process pid)

Tips

  • Defining environment variable - Using an Awk script and Bash builtin eval
eval $(awk 'BEGIN{printf "MY_VAR=value";}')
echo $MY_VAR