Hi,

I would like to add a new column in a text file which contains values based on the value of another column.
Eg:
suppose the text file contains:
1 abc 67
2 def 40
3 uty 57
.......
....
Now i would like to add a new column which contains value 'yes' if the column 3 > 40 else 'no'.
Is it possible using awk ??

$ awk '{ if ($3 > 40) four="yes"; else four="no"; print $0, four }' file
1 abc 67 yes
2 def 40 no
3 uty 57 yes
$
awk '{printf "%s %s",$0, ($3 > 40)? "yes" :"no"}' file
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.