Why is bash not behaving consistently?

Dan Track dan.track at gmail.com
Fri Aug 12 08:57:35 UTC 2005


On 8/12/05, Paul Howarth <paul at city-fan.org> wrote:
> Dan Track wrote:
> > I was writing this little bash script using find and I came along this
> > difference from using the same command on the command line and in bash
> > script.
> >
> > Basically on the command line I have to type:
> >
> > /usr/bin/find /opt/yum/packages/ -mtime +2 -a \( -regex .*.rpm -o
> > -regex .*.hdr \) -exec ls -lrt {} \;
> >
> > whereas , in a bash script I have to type:
> >
> > /usr/bin/find /opt/yum/packages/ -mtime +2 -a ( -regex .*.rpm -o
> > -regex .*.hdr ) -exec ls -lrt {} ;
> >
> > As you can see I need to escape parenthesis and semi-colons on the
> > command line but I don't need to do that in a bash script.
> >
> > Is there a reason for this?
> 
> How are you running this script? I would expect the first version to
> work on the command-line and in a script, and the second version not to
> work at all...

Hi

I'm not sure what you mean. I run the script from the command line:
./run_yum_clean

I agree with you, I thought the first one would work both in both
situations. However when I type it into bash it gives an error in the
find command.

Any ideas?

Thanks
Dan




More information about the fedora-list mailing list