![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading a file and writing the file name to a param file. | thebeginer | UNIX for Advanced & Expert Users | 1 | 10-05-2007 01:38 PM |
| Unix file editting commands | Terrible | Shell Programming and Scripting | 1 | 12-26-2006 02:54 PM |
| Reading file names from a file and executing the relative file from shell script | anushilrai | Shell Programming and Scripting | 4 | 03-10-2006 02:25 AM |
| file editting with shell programmin | ssshen@mit.edu | Shell Programming and Scripting | 4 | 07-11-2005 12:28 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
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. |
|
#3
|
|||
|
|||
|
editting file
Hi your command is working, but the outputfile.txt is having the output without newline character.
output is like this: 654145831789025902 |
|
#4
|
|||
|
|||
|
Code:
sed 's/ /\ /g' filename | while read pid do ps -ef | grep "$pid" done > output.txt |
|||
| Google The UNIX and Linux Forums |