Find the answer to your Linux question:
Results 1 to 5 of 5
Hey I'd get the error "target `thinking' is not a directory" for running this script Code: find -iname "*.pdf" | while read -r filename; do if pdfgrep -q "[[:digit:]]\.[[:blank:]]Critical thinking\." ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2013
    Posts
    2

    Folder with a space isn't recognized in a script


    Hey

    I'd get the error "target `thinking' is not a directory"

    for running this script

    Code:
    find -iname "*.pdf" | while read -r filename; do
    	if  pdfgrep -q "[[:digit:]]\.[[:blank:]]Critical thinking\." "$filename" ; then
    		mv "$filename" /home/arled/LCSH/Critical thinking
    fi
    done
    Why does the script behave that way and is there a way around it?

    Hi btw :)

  2. #2
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    231
    hi

    Code:
    mv "$filename" "/home/arled/LCSH/Critical thinking"
    or
    Code:
    mv "$filename" /home/arled/LCSH/Critical\ thinking

  3. #3
    Just Joined!
    Join Date
    Jul 2013
    Posts
    2
    Ohh ok I see

    Must be that the space is a metacharacter to shell and need to be escaped

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    36
    Try literalisation ,
    either
    $space = " "
    but usually in shell script literalising is done
    $space = ' '
    with single quotes(not backtick)
    then
    $folder = "Critical".${space}."thinking"

  6. #5
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    231
    nicephotog, try to read shell's man page

    arled, indeed
    Quote Originally Posted by man bash
    metacharacter
    A character that, when unquoted, separates words. One of the following:
    | & ; ( ) < > space tab

Posting Permissions

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