| You are here: | About>Computing & Technology>Focus on Linux |
![]() | Focus on Linux |
|
awk Command <Linux
Glossary>
There are two ways to run awk. A simple awk command can be run from the command line. More complex tasks should be written as awk programs ("scripts") to a file. Examples of each are provided below. Example: % awk 'pattern {action}' input-file > output-file meaning: take each line of the input file; if the line contains the pattern apply the action to the line and write the resulting line to the output-file. If the pattern is omitted, the action is applied to all lines: % awk '{action}' input-file > output-file By default, awk
works on files that have columns of numbers or strings that are separated by
white space (tabs or spaces), but the -F option can be used if the columns are
separated by another character. awk refers to the first column as $1, the second
column as $2, etc. The whole line referred to as $0. Related Resources: Command Library |
| |||||
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


