LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-15-2005, 12:58 PM   #1
fiod
LQ Newbie
 
Registered: Sep 2003
Posts: 26

Rep: Reputation: 15
Simple Redirecting Question


Hi.

Got a file containing a list of files (using "ls > file").

Want to give the list of files one by one to wma2ogg.sh (which can be called
using "wma2ogg.sh [file]" only using one file at a time).

Can anyone suggest how this could be done using bash scripting or whatever?

Thank you in advance,
FIOD
 
Old 10-15-2005, 01:18 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
If you start the script like this... ./wma2ogg.sh Your_file_name
The script is $0 and the file is $1
That means you could put this into your script.
cat $1 | \
while read list ; do
put some commands
here and
here
done
 
Old 10-15-2005, 04:44 PM   #3
init100
LQ Newbie
 
Registered: Oct 2005
Location: Europe
Distribution: Fedora Core 4
Posts: 20

Rep: Reputation: 0
Re: Simple Redirecting Question

Quote:
Got a file containing a list of files (using "ls > file").

Want to give the list of files one by one to wma2ogg.sh (which can be called
using "wma2ogg.sh [file]" only using one file at a time).

Can anyone suggest how this could be done using bash scripting or whatever?
Here is a somewhat shorter answer:

Code:
for f in `cat file`; do wma2ogg.sh $f; done
This command (works in bash) runs wma2ogg.sh once for every line in file. The line content is placed into $f.

Here is another one:

Code:
xargs -a file -L1 wma2ogg.sh
It will do the same thing as the above command, but is not shell-dependent, since xargs is a program, not a shell construct (like for; do; done). In other words, it works with other shells too, like tcsh.

Both these commands assume that your input file is called 'file' (without the quotes), and that wma2ogg.sh is available in your PATH. If the last is not true, prepend the correct path to the wma2ogg.sh command, like /path/to/program/wma2ogg.sh or, if wma2ogg.sh is in the current directory, ./wma2ogg.sh
 
  


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
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 03:03 PM
redirecting to index.php question jacksmash Programming 18 05-23-2005 06:41 PM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 10:03 PM
Hopefully a Simple Question Arcane Kidd Linux - Newbie 5 01-17-2003 05:27 PM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 05:08 AM


All times are GMT -5. The time now is 06:13 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