Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-11-2005, 08:52 PM   #1
Senior Member
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,545

Rep: Reputation: 57
bash script help


I know there is probably a stupidly easy answer to this but my first attempt at a script to make life easier hasn't turned out to be all that easy. Here's what I have so far

FILES=`ls $1`

for file in $FILES

	echo "$file"
	lame -b 32 -f -m m "$1/$file" "$1/output/$file"


echo "FINISHED!"

exit 0
It works, but breaks down badly when there's a space in the filename. I've read through a bunch of bash tutorials and they seem to tell me that with the double quotes it should work, but it doesn't.

Any help would be greatly appreciated
Old 03-11-2005, 10:08 PM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
You have problems before you hit the quotes. The for statement will break up the FILES line based on what it knows to be whitespace. Normally it's either a space, newline or tab. You can override the default seperator by filling in the IFS shell variable.
Make sure that there are no spaces after the first quote. This will set the seperator to just a newline and the for statement will now assign files with spaces to the file variable. The quote you will still need for lame.

hope this helps

Last edited by crabboy; 03-11-2005 at 10:09 PM.
Old 03-11-2005, 10:14 PM   #3
Senior Member
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,545

Original Poster
Rep: Reputation: 57
You are a genious.

Thanks heaps!!!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script zaicheke Programming 3 11-07-2004 06:32 PM
bash script how to? Lleb_KCir Programming 11 05-21-2004 07:03 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration