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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk, print single "exists" 1

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL

hello,
inputfile example:

userA:
userB:
userC:
userA:

awk -F: '$1 == "userA" {print "exists"}' inputfile
prints "exists" twice - I need to have it printed only once.

Is my "solution" OK and if yes, can it can be made yet shorter in awk basing on 1st command?:
awk -F: '$1 == "userA" {a=1} END{if(a){print "exists"}}' inputfile
 
What about this ?
awk -F: '$1 == "userA" {print "exists";exit}' inputfile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top