Find the answer to your Linux question:
Results 1 to 3 of 3
Hello Linux ppl! I need some help with processing wildcard character * in my bash script. My script writes: OUTPUT=$(du -sh backup* 2>&1) Whenever this line is executed, backup* is ...
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Posts
    6

    Escaping wildcard character * in bash script

    Hello Linux ppl!

    I need some help with processing wildcard character * in my bash script. My script writes:

    OUTPUT=$(du -sh backup* 2>&1)

    Whenever this line is executed, backup* is interpreted explicitly as backup* instead of all files starting with the word backup.

    Thanks in advance!

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    That is interesting, as mine does not:
    Code:
    alex@danu:~$ OUTPUT=$(du -sh down* 2>&1); echo $OUTPUT
    404M downloads
    Perhaps you forgot that you are storing the output of that command in $OUTPUT, and forgot to echo it?
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Jan 2010
    Posts
    6
    Thanks for your response.

    It works differently if written in a script file.

    The solution goes like this: OUTPUT=$( du -sh backup* 2>&1 )
    I have added spaces after the opening parenthesis and before the closing parenthesis.

    I hope this help others with the same problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...