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

Print a statement if no values are found 1

Status
Not open for further replies.

frangac

Technical User
Feb 8, 2004
163
ZA
Hi All,

My code,

awk '/:/{
if($3>20)
{
DATE1="date +'%Y%m%d-%T'"
DATE1 | getline DT
close("DATE1")
name=substr($2,1,7)
Date=substr(DATE1,1,8)
Da_T=substr($2,8,11)
VOL="/data/Gaps/"Da_T".txt"

{if((name~/eplz/ && Da_T~/ds09/) || (name~/epdo/ && Da_T~/ds09/))
{
next
}
else
{
printf "(%s) %s has a Gap of %s\n" ,DT,$2,$3 >> VOL
}
}
}
}' TimeGap.Rep

What I am trying to achive is that if there are no $3 greater than 20,
print "DT has no Gap\n" >> VOL at the END.

Many Thanks
Chris
 
Your request isn't very clear for me, I must confess.
Something like this ?
awk '
BEGIN{
DATE1="date +'%Y%m%d-%T'"
DATE1 | getline DT
close("DATE1")
Date=substr(DT,1,8) # Not used ?
}
/:/{
name=substr($2,1,7)
Da_T=substr($2,8,11)
VOL="/data/Gaps/"Da_T".txt"
if($3>20)
if((name~/eplz/ && Da_T~/ds09/) || (name~/epdo/ && Da_T~/ds09/))
next
else
printf "(%s) %s has a Gap of %s\n",DT,$2,$3 >> VOL
else
printf "(%s) has no Gap\n",DT >> VOL
}' TimeGap.Rep

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

Thanks for your responce.
My request is, search thru TimeGap.Rep and if one or more $3 is > 20 print to file VOL.
If there are none in the TimeGap.Rep that is greater that 20 then printf "(%s) has no Gap\n",DT >> VOL (one liner)

Hope this helps
Many Thanks
Chris

 
Something like this ?
awk '
BEGIN{
DATE1="date +'%Y%m%d-%T'"
DATE1 | getline DT
close("DATE1")
Date=substr(DT,1,8) # Not used ?
}
/:/{
name=substr($2,1,7)
Da_T=substr($2,8,11)
VOL="/data/Gaps/"Da_T".txt"
if($3>20){
++f
if((name~/eplz/ && Da_T~/ds09/) || (name~/epdo/ && Da_T~/ds09/))
next
else
printf "(%s) %s has a Gap of %s\n",DT,$2,$3 >> VOL
}
}
END { if(!f) printf "(%s) has no Gap\n",DT >> VOL } # last calculated VOL
' TimeGap.Rep

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

Thanks for your time and patience.Your solution is great.

Once Again Many Thanks
Chris

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top