Computing.Net > Forums > Unix > Shell scripting question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell scripting question

Reply to Message Icon

Name: Benn
Date: October 23, 2002 at 11:05:48 Pacific
OS: unix
CPU/Ram: 20000 meg
Comment:

Hi, my problem is as follows
I have a file in the following format
-------------starts here------------
/usr/bin/perl -w ./bomber
tcsh
/usr/bin/perl -w ./killer
.
..
....
---------end here----------
Now what i have to do is take each line in the file (each line should be taken as a whole string) and pipe that string to pgrep.
Any clues how this could be done?

What i want is something like this
pgrep -f $line
where $line should store a line from the file. And i also need to loop for every line of the file.



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: October 23, 2002 at 11:35:18 Pacific
Reply:

It sounds like you want to run pgrep on each line of the file?

I've never used pgrep, but a normal way to do something like this would be

cat file | pgrep -f



0

Response Number 2
Name: sjako
Date: November 7, 2002 at 16:01:02 Pacific
Reply:

You could try something like this:

while read line
do
pgrep -f $line
done < yourfile


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Shell scripting question

a simple shell script question www.computing.net/answers/unix/a-simple-shell-script-question/1832.html

Simple Shell Script Question. www.computing.net/answers/unix/simple-shell-script-question/2119.html

sed and shell script question www.computing.net/answers/unix/sed-and-shell-script-question/4472.html