editting file

Hi,
I am having sequence of process ids in one file.
My file contents is (Output of fuser someobject.so).

654 14583 17890 25902

This no. of processes may vary depends up on the object.

I want to check all the processes one by one. If i want to apply egrep, I need to edit this file in the follownig format. Please guidme me to do this.

654|14583|17890|25902 or with newline character. (To give this pattern as pattern file grep -f).

Regards,
Sharif.

Hey,

You can use:

cat x.txt | tr -dc "[:digit:]\n" > outputfile.txt

Say in x.txt you have all the process ids.
In outputfile.txt you'll get only the digits (process ids.) and then this file you can use to check the status of processes in loop.
as:

cat outputfile.txt | \
while read line
do
ps -ef | grep "$line" >> statusfile.txt

done

Thanks.:b:

Hi your command is working, but the outputfile.txt is having the output without newline character.

output is like this:
654145831789025902

sed 's/ /\
/g' filename | while read pid
do
ps -ef | grep "$pid"
done > output.txt