LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-11-2005, 09:52 PM   #1
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
bash script help


Hey,

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
Code:
#/bin/bash

FILES=`ls $1`

for file in $FILES
do

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

done

echo
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, 11:08 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
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.
Code:
IFS='
'
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 11:09 PM.
 
Old 03-11-2005, 11:14 PM   #3
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

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

Thanks heaps!!!
 
  


Reply


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 07:32 PM
bash script how to? Lleb_KCir Programming 11 05-21-2004 08:03 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-06-2003 12:58 AM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 06:34 AM


All times are GMT -5. The time now is 05:04 AM.

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