Re: bash null conditional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Words by Craig White [Mon, Mar 30, 2009 at 11:41:11AM -0700]:
> On Mon, 2009-03-30 at 11:33 -0700, Agile Aspect wrote:
> > 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
> > >
> > >   
> > I believe it's
> > 
> >     if [ -z "grep A121 myfile.csv" ]; then echo "null"; fi
> ----
> not working for me...
> 
> $ if [ -z "grep A121 ARdebtorsmaster.csv" ]; then echo "null"; fi
> $ if [ -z "grep A125 ARdebtorsmaster.csv" ]; then echo "null"; fi

No, 

if [ -z "`grep A121 ARdebtorsmaster.csv`" ]; then echo "null"; fi
if [ -z "`grep A125 ARdebtorsmaster.csv`" ]; then echo "null"; fi

or

[ -z "`grep A121 ARdebtorsmaster.csv`" ] && echo "null"
[ -z "`grep A125 ARdebtorsmaster.csv`" ] && echo "null"

-- 
Jose Celestino | http://japc.uncovering.org/files/japc-pgpkey.asc
----------------------------------------------------------------
"One man’s theology is another man’s belly laugh." -- Robert A. Heinlein

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux