Re: Bash commands
Martin Strauss wrote:
>
> Begin Russell quotation:
> > Russell wrote:
> > >
> > > Hi,
> > >
> > > When i try a command like:
> > >
> > > debpc:# if [ -n df /mnt | grep -ie "/dev/hdc1" ] echo "yes"
> > >
> > > then after i press "return", i get a command prompt ">" which
> > > seems to be waiting for more input. Why does that happen?
> >
> > sorry, i missed out some things. I think the promp > happens when
> > the statement is unfinished (no "fi"). Should be:
> >
> > debpc:# if [ -n df /mnt | grep -ie "/dev/hdc1" ] ; then echo "yes" ; fi
> >
> > However, this gives the error:
> > [: missing ']'
> > grep: ]: No such file or directory
> You need to enclose the whole statement after -n in quotes:
>
> if [ -n "`df /mnt | grep -ie /dev/hdc1`" ]; then echo yes; fi
Hi, unfortunately, this gives "yes" too:
debpc:# if [ -n "`df /mnt | grep -ie /dev/crap`" ]; then echo yes; fi
I think the strong quotes result in a fixed literal string:
`df /mnt | grep -ie /dev/crap`
Reply to: