LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-21-2006, 12:49 PM   #1
hawkmauk
LQ Newbie
 
Registered: Mar 2005
Location: Lincolnshire
Distribution: Ubuntu
Posts: 14

Rep: Reputation: 0
file contents to command line args


Hi all,

im trying to send the contents of a file (a list of files) to the command line as arguments for a script, I thought I could get away with the following without success

myscript destfile <myfiles.txt
cat myfiles.txt | myscript destfile [the list of files as input files to the script piped here]

I have some scripting experience and could get around this by creating a script, loading the filenames into an array and then executing the script but was hoping someone could help me keep it simple.

Mikee
 
Old 11-21-2006, 01:04 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
xargs is what you want.
 
Old 11-21-2006, 01:19 PM   #3
hawkmauk
LQ Newbie
 
Registered: Mar 2005
Location: Lincolnshire
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: 0
Fantastic!
Never come across xargs before, many thanks to you sir!
 
Old 11-21-2006, 01:27 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
Yeah, it's super-useful, especially combined with find. I discovered it several months after writing my own program to do more or less the same thing. I didn't know whether to laugh or scream.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C command line args in linux YankeeFan Linux - Newbie 5 06-11-2006 08:22 AM
nfs a file shares ok via file mngr but not command line. Suse 9.1 acummings Linux - Networking 2 10-09-2004 02:23 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
command line args in a countdown Squeak2704 Programming 1 04-26-2004 12:27 PM
Read contents of file and execute command cosiek Programming 3 09-30-2003 11:07 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration