User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Argument Passing in Linux Shell Scripting Page [1]  
marilynlov7
All American
650 Posts
user info
edit post

I need to run a linux command, which will return a list of words, then I need to take that list, and each line of the list, I need to use as input into another linux command. I want to use shell scripts to do this. Anyone know if its possible and if so, how?

9/8/2006 4:45:42 AM

A Tanzarian
drip drip boom
10994 Posts
user info
edit post

I think that you want to use pipes. < > |

9/8/2006 7:58:06 AM

hacker1208cb
All American
860 Posts
user info
edit post

I don't know much about linux scripting languages, but this is what I would do.

Just pipe the output to a perl program similar to this:

@lines = <STDIN>;

foreach $line (@lines) {

system "other-command \"$line\"";

}


[Edited on September 8, 2006 at 9:55 AM. Reason : ]

9/8/2006 9:53:56 AM

qntmfred
retired
40562 Posts
user info
edit post

meh, stick with pipes. it doesn't sound like you need to go as "complex" as using perl

9/8/2006 9:56:44 AM

hacker1208cb
All American
860 Posts
user info
edit post

The only reason I used perl is that I don't know how to get the lines like that with only shell commands and its a short, trivial perl program.

How would you get the lines using only shell commands?

9/8/2006 10:01:17 AM

 Message Boards » Tech Talk » Argument Passing in Linux Shell Scripting Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.