0% found this document useful (0 votes)
63 views

Bash Shell Scripting: Awk Command

This document provides an overview of the awk command in 3 paragraphs. It explains that awk is a powerful tool for processing and analyzing text files organized into lines and columns. It can be used both as a Linux command and scripting language like bash. The syntax and basic options of awk like -F, -f, and -v are described. Examples of using selection criteria and actions like printing specific fields are also provided.

Uploaded by

srikanth ganji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Bash Shell Scripting: Awk Command

This document provides an overview of the awk command in 3 paragraphs. It explains that awk is a powerful tool for processing and analyzing text files organized into lines and columns. It can be used both as a Linux command and scripting language like bash. The syntax and basic options of awk like -F, -f, and -v are described. Examples of using selection criteria and actions like printing specific fields are also provided.

Uploaded by

srikanth ganji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Bash Shell Scripting

awk command
Part-1

Learn how to automate common tasks using bash shell scripting


awk command:
 The awk command is a powerful method for processing or analyzing text or data files ,
which are organized by lines (rows or records) and columns(fileds).
 we can use awk as a linux command and also as a scripting language like bash shell
scripting.
 Simple awk command syntax:
 awk [options] ‘[selection _criteria] {action }' input-file
 cat input-file | awk [options] ‘[selection _criteria] {action }' input-file
 Awk can take the following options:
-F fs To specify a field separator. (Default separator is tab and space)
-f file To specify a file that contains awk script.
-v var=value To declare a variable.
 Selection criteria: pattern/condition
 Action: It is a logic to perform action on each row/record

Learn how to automate common tasks using bash shell scripting


awk command:
 Simple awk command syntax:
 awk ' {action }' input-file
 Action: Action is a logic to perform action on each record.
 Example: print $1 print first filed from each line
 Some of the default variables for awk:
 $0  Entire file
 $1  First field from each line/record
 $2  Second field from each line/record
 NR  It will print line or record number
 NF  It will print number of filed from each line/record

Learn how to automate common tasks using bash shell scripting

You might also like