dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Re: MP3 Managing Tool?

Re: MP3 Managing Tool?

From: Neon John <>
Date: 2005-01-15

On Fri, 14 Jan 2005 15:15:58 -0800, Menachem Shapiro
<> wrote:

>----script excerpt--------
> for f in `ls "$MOUNT"|sed 's/ /_-_-_/g'`; do
> f=`echo "$f"|sed 's/_-_-_/ /g'`
> echo "cp $f -> $TARGET"
> cp "$f" "$TARGET" 2>/dev/null >&1 || faildo "$f"
> unset f
> done
>--------end excerpt--------
>Is it standard practice to use the same variable ('f') as the variable
>used for the for loop? I noticed it gets unset at the end, but it
>seems a little scary.

Perfectly normal. the loop runs until the list produced by the ls |sed
pipe is exhausted, then exits. When the list is exhausted, f is not
assigned anything. The unset leaves f with a null string which is FALSE
in the "for" conditional.

I can't think of any easier way to do that in a shell script. Clever.


John De Armond
Cleveland, Occupied TN
Received on Sat Jan 15 00:33:04 2005

Page was last modified "Jan 10 2012" The Rockbox Crew