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!

simple awk command ?? please help... 3

Status
Not open for further replies.

h3nd

Programmer
Jul 1, 2006
147
AU
Hi guys,

I just wanna put condition, if the file is empty I should print "NOTHING"

I've tried this but doesnt work
Code:
awk '{if ($0 ~ //){print "Nothing Missing"}
        else{
                print;getline
        }
 }' missing_PromptCurves.csv

or I've tried
if ($0==""){print "Nothing Missing"}

But both doesnt work, what should I do guys ?

Thanks for your idea.

 
A way:

Code:
awk ' { print $0 } END { if(FNR == 0)
                     print "NOTHING"
} ' mydatafile.txt
 
Another way:
Code:
if [ -s myfile ]
        then
        cat myfile
        else
        echo "File is empty"
fi

Is this the same, or am I totally missing the question?

"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
Thx guys,

It works !!!

Have a star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top