help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] for File in Folder_Variable_Name Expansion


From: Pierre Gaston
Subject: Re: [Help-bash] for File in Folder_Variable_Name Expansion
Date: Mon, 16 Dec 2013 12:30:16 +0200

On Mon, Dec 16, 2013 at 5:23 AM, Roger <address@hidden> wrote:

>
> The following performs correctly, however I'm not used to seeing variable
> assignments encased in parenthesis!
>
> $ FOLDER=( ${HOME}/Books/Learning\ C/cse142/Lecture1/Files/slides/ ); for
> file in "${FOLDER}"/*.jpg; do echo "${file}"; done


In this example the ( ) don't help
FOLDER=${HOME}/Books/Learning\ C/cse142/Lecture1/Files/slides/; for file in
"${FOLDER}"/*.jpg; do echo "${file}"; done
would work the same.

However I think I know understand your initial problem where you used a ?
instead of a space, this indeed doesn't work:
FOLDER=${HOME}/Books/Learning?C/cse142/Lecture1/Files/slides/; for file in
"${FOLDER}"/*.jpg; do echo "${file}"; done

The problem is that ? is a wildcard just like * and these are not expanded
when you assign a value of when you use double quotes.

Using ( ) would make it "work" because then the ? would not be inside quotes


reply via email to

[Prev in Thread] Current Thread [Next in Thread]