Do anyone show me the way to use PIDs stocked in an external file as entries for a command.
ex : for the command PFILES
thanks
Do anyone show me the way to use PIDs stocked in an external file as entries for a command.
ex : for the command PFILES
thanks
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`
do
echo "Processing $PID ..."
done
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`
do
echo "Processing $PID ..."
done
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.
do
echo $word
done