Page 4 of 4 FirstFirst ... 234
Results 31 to 37 of 37

Thread: Shell/bash

  1. #31
    Join Date
    Jun 2011
    Beans
    64

    Re: Shell/bash

    The problem is, when I did that I had a different error:

    extract.sh: 48: extract.sh: Syntax error: redirection unexpected

    Code:
         while IFS= read -d $'\0' -r rarfile
        do
        echo "Unpacking in directory: "`dirname $rarfile`
        unrar e -v "$rarfile" `dirname "$rarfile"`
        done < <(find "$1" -type f -regextype posix-extended -iregex '.*\.(rar|r01|001|01)' -print0) ;;
    Loneliness is never more cruel than when it is felt in close propinquity with someone who has ceased to communicate.

  2. #32
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Shell/bash

    20 bucks says it's (da)sh instead of bash.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #33
    Join Date
    Jun 2011
    Beans
    64

    Re: Shell/bash

    Err...

    What's the difference between DASH, BASH, and SH???

    Edited to add this:

    Used bash extract.sh...

    and received....

    Extracting from /mnt/DATA/Downloads/01-TORRENTS/01-Downloaded/Dark Souls Prepare To Die Edition-FLT/flt-dspd.081

    No files to extract

    So... It now RECOGNIZES the files, but won't extract them with spaces... Any ideas?
    Last edited by rhss6-2011; August 19th, 2014 at 09:58 PM.
    Loneliness is never more cruel than when it is felt in close propinquity with someone who has ceased to communicate.

  4. #34
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Shell/bash

    sh is barebone, bash has additional features which are convenient to use and fix many shortcomings of sh.

    Why don't you echo some variables so you get to track the progress of the script and to see if the values are what you think they are. You didn't check what unrar gets exactly as the last param (quotes around embedded commands do matter). L2debug.

    Also stop using deprecated backticks ``, use $() instead.
    stripping the /filename.ext part can be done with %/* in bash

    Code:
    echo "Unpacking in directory: '${rarfile%/*}'"
    unrar e -v "$rarfile" "${rarfile%/*}"
    or if you really have to use dirname
    Code:
    echo "Unpacking in directory: '$(dirname $rarfile )'"
    unrar e -v "$rarfile" "$( dirname "$rarfile" )"
    Last edited by Vaphell; August 20th, 2014 at 12:57 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  5. #35
    Join Date
    Jun 2011
    Beans
    64

    Re: Shell/bash

    Alright, I actually fixed it using the slightly different version that Pabibe wrote down:

    Code:
    	while IFS= read -d $'\0' -r rarfile
    	do
    	unpack_dir=""${rarfile%/*}""
    	echo "Unpacking in directory: $unpack_dir"
        	unrar e -v "$rarfile" "$unpack_dir"
    	done < <(find "$1" -type f -regextype posix-extended -iregex '.*\.(rar|r01|001|01)' -print0) ;;
    I don't really understand what the difference is though...
    Loneliness is never more cruel than when it is felt in close propinquity with someone who has ceased to communicate.

  6. #36
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Shell/bash

    the difference is there is a temporary variable that is used correctly with "" when called. Your embedded cmd was not shielded properly from breaking down to space separated pieces (i don't see the quotes around ``). The first part of my #34 post is equivalent to the solution, it just lacks that temporary var and there is a variant with embedded command in the second part, using quoted $().
    What the expression does is stripping shortest rightmost '/'+anything which in case of paths would be the /<filename>



    also double double quotes do nothing. ""${}"" = open quoted string, close string, ${...}, open quoted string, close quoted string. You attach 2 empty strings to both sides which does nothing.
    Either way you don't need quotes with assignment x=... if the ... part is in a single chunk.
    unpack_dir=${rarfile%/*}
    will do just fine
    Last edited by Vaphell; August 22nd, 2014 at 07:04 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  7. #37
    Join Date
    Jun 2011
    Beans
    64

    Re: Shell/bash

    Ok, thank you.

    I appreciate the help (and lessons) you (and Pabibe) have given me - much appreciated.
    Loneliness is never more cruel than when it is felt in close propinquity with someone who has ceased to communicate.

Page 4 of 4 FirstFirst ... 234

Bookmarks

Posting Permissions

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