use information from file for command

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting use information from file for command
# 1  
Old 04-05-2002
use information from file for command

Do anyone show me the way to use PIDs stocked in an external file as entries for a command.

ex : for the command PFILES

# 2  
Old 04-07-2002
Sorry, I do not know what you mean by PFILES. But if you have data in a file (or piped output from a command) that you want to process on a line-by-line basis, you can use the for command. If the data to process is only the PIDs and nothing else, then:
for PID in `cat myPIDfile`
   echo "Processing $PID ..."

Or if you did ps -f -ujdoe > jdoe.PIDs and you now want to process that file, you could do:
for PID in `awk 'BEGIN {getline} {print $2}' jdoe.PIDs`
   echo "Processing $PID ..."

awk bypasses the ps header line, then outputs word 2 for each line, and this list of words is processed by the for command. To give a very simply example of the for command:
for word in This is a test of the for command.
   echo $word

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sftp command usage information

hello how do we get detailed information of an sftp command? for example when you type help on sftp, you get the available commands and their brief descriptions. What if you want to get detailed usage information, for example when you want to know what the command line options do..? in... (5 Replies)
Discussion started by: milhan
5 Replies

2. Red Hat

Command to find the harddisk information

I tried to find the harddisk information using the command hdparm -i /dev/sda. But I couldn't get the info. Is there any similar command to find the harddisk serial number. (5 Replies)
Discussion started by: gsiva
5 Replies

3. UNIX for Dummies Questions & Answers

Command to get Vendor information on Solaris

Hello I know that prtdiag and prtconf both give the Vendor information on the first line, something like this: System Configuration: Oracle Corporation sun4u Sun Fire V240 But is there a command that would ONLY output the vendor, so therefore in this example, it would only output Oracle... (3 Replies)
Discussion started by: flagman5
3 Replies

4. Shell Programming and Scripting

get specific information from text file or command output

Hello, I would need some help, :wall: on a linux script, I am not sure how can I separate some text file, Text file contains something similar to this: share "userhome_e" "/fs1_100g/FILE58/userhome" umask=022 maxusr=4294967295 netbios=FILE58 share "bu share"... (3 Replies)
Discussion started by: nakaedu
3 Replies

5. Solaris

Last command displays wrong information

Hi am having Solaris10 - Sun-Fire-V890 server, the information displayed by Last command is wrong how do i get this sorted without loosing any datas.. # uptime 12:32am up 20 day(s), 33 min(s), 1 user, load average: 1.54, 1.82, 1.93 # last reboot reboot system boot Sat... (9 Replies)
Discussion started by: Sojourner
9 Replies

6. Solaris

command to get cluster information

hi , i have to get the cluster information , with using solaris command . thanks, ravi . (1 Reply)
Discussion started by: shankr3
1 Replies

7. Shell Programming and Scripting

How to get the information about cpu idle from top command?

I am using Ubuntu 9.04. I want to write a shell script to get the information about cpu idle from top command at the real time when i call it, compare cpu idle with 20 (20%), if cpu idle > 20 exit 1, vice versa exit 0. Anybody can help me to resolve it ? Thanks alot. (7 Replies)
Discussion started by: huyquocnguyen
7 Replies

8. Solaris

Command to List Hard Disk Information

I have a SparcStation5 that is making sounds that make me think the disk drive(s) may be on the verge of quiting. What is the command to list the disk types and sizes? I'm thinking I can possibly pick up another drive or two and compy the exisiting drives while they are still working. (1 Reply)
Discussion started by: muletrainman
1 Replies

9. Solaris

command to retrieve user information

Hi, I want the command to retrieve the existing user information such as * authorization * Profile * role * exipre(expiration date of login) * inactive please tell me how to do that Thank you. (3 Replies)
Discussion started by: S_venkatesh
3 Replies

10. UNIX for Dummies Questions & Answers

command to know the bit information of OS

How to know the bit information of different OS, since "isainfo -kv" shows the bit information of solaris. It would be helpful, if there is some comand to know the above. Thanks, Alok (5 Replies)
Discussion started by: alokjyotibal
5 Replies
Login or Register to Ask a Question