Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help regarding AWK... 1

Status
Not open for further replies.

nithink

Programmer
Nov 7, 2002
92
US
Hi,
i've a txt file called files.txt which has the following lines...

The file xyz1
The file xyz2
The file xyz3

The file xyz4
The file xyz5
The file xyz6

I'm using awk to get the 3rd field alone like this,

awk '{print "get " $3}' ./files.txt >> ./tmp5

the problem is sometimes there may be a blank line in the txt file.. so if its a blank line I dont want to use the awk statement... so i tried using this but still its not working...

awk '{if ($3 != " ") print "get " $3}' ./files.txt >> ./tmp5

ur help really appreciated...thx...
 
Try

awk '{if ($3 != "") print "get " $3}' ./files.txt >> ./tmp5

or

awk '{if (NF >= 3) print "get " $3}' ./files.txt >> ./tmp5 CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top