On Mon, Mar 30, 2009 at 11:27:42AM -0700, Craig White wrote: > I'm in my bash book and looking on web but can't seem to resolve this > simple problem. > > $ if [ -n "grep A121 myfile.csv" ]; then echo "null"; fi > null > > $ if [ -n "grep A125 myfile.csv" ]; then echo "null"; fi > null > > A125 definitely is null when I just run the grep command in the quotes > but A121 definitely is not null. > > What am I missing on the if/null operator here? > > Craig if you're doing classwork and required to use the if (and related) operators, then my response isn't what you want. But if you just want to know how to get equivalent functioniality, you may wish to consider this: grep A125 myfile.csv || echo "no match found" which runs the grep and if not "successful" (i.e., did not find a match) it runs the echo command. alternatively: grep A125 myfile.csv && echo "found a match" does the echo if it DID find A125. Fred -- ------------------------------------------------------------------------------- Under no circumstances will I ever purchase anything offered to me as the result of an unsolicited e-mail message. Nor will I forward chain letters, petitions, mass mailings, or virus warnings to large numbers of others. This is my contribution to the survival of the online community. --Roger Ebert, December, 1996 ----------------------------- The Boulder Pledge -----------------------------
Attachment:
pgpbXPTCaCzLy.pgp
Description: PGP signature
-- fedora-list mailing list fedora-list@xxxxxxxxxx To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines