Re: Why is bash not behaving consistently?

From: Paul Howarth (
Date: 08/12/05

  • Next message: Vikram Goyal: "rpm being treated as [audio/x-pn-realaudio-plugin]"
    Date: Fri, 12 Aug 2005 12:44:55 +0100
    To: For users of Fedora Core releases <>

    Dan Track wrote:
    > On 8/12/05, Stephanus Fengler <> wrote:
    >>Paul Howarth 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
    >>>>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...
    >>Maybe your standard script interpreter isn't bash but simply sh? You may
    >># /bin/bash
    >>as your first line to make sure bash is used.
    > The script interpreter is /bin/bash.

    Can't reproduce this here.

    With this script:


    /usr/bin/find /var/cache/yum/updates-released/packages/ -mtime +2 -a \(
    -regex .*.rpm -o -regex .*.hdr \) -exec ls -lrt {} \;

    I get output:

    -rw-r--r-- 1 root root 9763596 Aug 1 00:00
    -rw-r--r-- 1 root root 91382 Aug 1 00:00

    With this script:


    /usr/bin/find /var/cache/yum/updates-released/packages/ -mtime +2 -a (
    -regex .*.rpm -o -regex .*.hdr ) -exec ls -lrt {} ;

    I get the expected errors:

    ./run_yum_clean: line 5: syntax error near unexpected token `('
    ./run_yum_clean: line 5: `/usr/bin/find
    /var/cache/yum/updates-released/packages/ -mtime +2 -a ( -regex .*.rpm
    -o -regex .*.hdr ) -exec ls -lrt {} ;'

    I'd also suggest escaping the asterisks, so in your original script that
    would be:

    /usr/bin/find /opt/yum/packages/ -mtime +2 -a \( -regex .\*.rpm -o
    -regex .\*.hdr \) -exec ls -lrt {} \;

    What output do you get from this, and what output from your unescaped


    fedora-list mailing list
    To unsubscribe:

  • Next message: Vikram Goyal: "rpm being treated as [audio/x-pn-realaudio-plugin]"

    Relevant Pages

    • Re: [ Attn: Randy ] Ad-hoc Parsing?
      ... > 1) They were out of context quotes, as the quotes came with no context. ... embed cpu instructions within a DOS/Windows batch script. ... that this also is possible with bash scripts. ... statement "It can execute the .com file as easily as a ...
    • Re: [opensuse] Editting PATH variable
      ... SuSEconfig script ... ... not knowing what you options you used to install ... If your unfamiliar with Bash a good book is 'Learning the Bash Shell' by ... For Java use editing the PATH variable is NOT required... ...
    • Re: Command Line Interface
      ... >> should accept system commands only for an administrator. ... >> how should I supress the bash shell and launch my custom CLI ... > The script could run in a restricted shell and offer a menu of ... account, and either 1) change account password, 2) ...
    • Re: bash: WHY???
      ... IMHO bash 2.05+ is the most usable interactive shell as it has ... OK - but call it a bash script, ... default in sh using sh features. ...
    • Re: Reverse ldd ??
      ... people don't use them and that bash is what everyone does use, ... learning a new language in order to recode a snippet. ... then you will quickly recognize what the tclshell script ... I just am saying that's what I found confusing. ...