[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] for File in Folder_Variable_Name Expansion
From: |
Eduardo A . Bustamante López |
Subject: |
Re: [Help-bash] for File in Folder_Variable_Name Expansion |
Date: |
Sun, 15 Dec 2013 20:50:20 -0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Sun, Dec 15, 2013 at 01:28:24PM -0900, Roger wrote:
>
> $ FOLDER="${HOME}/Books/Learning?C/cse142/Lecture1/Files/slides/"; for file
> in "${FOLDER}"/*.jpg; do echo "${file}"; done
So you have a directory named "Learning?C" ? Also, did you make sure
that there are actually .jpg files in that directory (not .JPG or
.jpeg, note the extra "e" or the case sensitivity)
>
>
> $ FOLDER="${HOME}/Books/Learning?C/cse142/Lecture1/Files/slides/";
> FFOLDER="${FOLDER}/*.jpg"; for file in "${FFOLDER}"; do echo "${file}"; done
>
> Output:
> /home/roger/Books/Learning?C/cse142/Lecture1/Files/slides//*.jpg
>
>
> I've read multiple forum posts, and they've all worked around or suggested
> (or deterred) the usage of eval. (ie. $(eval echo "${FOLDER}") )
Yep, never use eval unless you are sure of all the corner cases.
> I have some ideas, and of them thinking just declaring the "name" for the
> "for" command a static value. (ie. "for FILE in /path/to/folder/*.jpeg")
>
> (Read the Bash Manual and didn't notice any mention of possible problems
> using a concatenate variable name for "name" for the "for" command.)
No, that pattern (for + glob) is completely normal.
--
Eduardo Alan Bustamante López
Re: [Help-bash] for File in Folder_Variable_Name Expansion, Roger, 2013/12/16