Article 57ZJS simple while loop call for help

simple while loop call for help

by
Drosera_capensis
from LinuxQuestions.org on (#57ZJS)
Hello everyone,

I have made a little while loop to process a file line per line using a list of matching expressions.
And I wished to print "0" if there were no matches.

But I guess the if( $2 >= 0 ) part is not appropriate for no match. Would anyone know how to do it?

Code:while read f ;
do
awk '/'$f'/ {if( $2 >= 0 ) {print $2} else {print "0"}}' file ;
done < listlatest?d=yIl2AUoC8zA latest?i=x-r1f2w_188:ydDzrlBkqOY:F7zBnMy latest?i=x-r1f2w_188:ydDzrlBkqOY:V_sGLiP latest?d=qj6IDK7rITs latest?i=x-r1f2w_188:ydDzrlBkqOY:gIN9vFwx-r1f2w_188
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments