Professional Documents
Culture Documents
Syntax:
FS - Field Seperator
OFS - Output Field Seperator
NR - Number of Records
NF - Number of Fields
RS - Record Seperator
ORS - Output Record Seprator
1) awk '/pattern/' filename #Displays the complete record matching the pattern
emp_name,age,city,exp,salary
5) Performance Report
6) c_id|c_name|age|city|email
awk file:(custawk.awk)
#!/usr/bin/awk -f
{BEGIN FS=OFS="|"}
{print $2,$4,$5}
txt file:(cust.txt)
c_id|c_name|age|city|email
to run the awk command
or
./custawk.awk cust.txt
#!/usr/bin/awk -f
{BEGIN FS="|" sum=0}
{sum=sum+$3;}
END{print "Avg Age" sum/NR;}
#!usr/bin/awk -f
BEGIN{FS="|"}
{if(index($5,"gmail")>0)
{
print $2 "\t" $5
}
}