In a file i have a data like
INPUT:
no,name,company
1,vivek,hcl
2,senthil,cts
1,narsi,hcl
4,prabhakaran,ibm
OUTPUT:
1,vivek,hcl
1,narsi,hcl
Using AWK command i want to display the names those having no:1 and company:hcl.Please tell me the command to display above result.
awk -F, '$1==1 && $3=="hcl"' inputfile
thanks,please tell the command if i want to delete the line which has $1=1 and $3="hcl"
sed -n '/1,\(.*\),hcl/!p' infile
or
sed '/1,\(.*\),hcl/d' infile
cant we achive this using AWK command?
ctsgnb
6
awk -F, '$1==1 && $3=="hcl"{next}1' inputfile
Simply reverse the logic with !( ... )