The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




Thread: awk utility
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 06-19-2001
alwayslearningunix
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
This sounds like a homework question to me

So I will give a general answer in that awk is mainly used to search input, whether it be from a file or command run at the command line, for a specific pattern or patterns and then perform an action on that pattern.

For example, if you wanted to regularly kill a process in a script, but are not sure the PID of that process at any one moment in time, awk is good to search for that pattern and send the PID to the kill command thus:

kill -9 `ps -ef | grep $process | grep -v grep | awk '{print $1}'`

This is a very simply application of a relatively powerful and flexible language.

Search on the web for more on specific examples relating to awk.

Regards.