Distinguish from the contents of a file which are the processes and print them
I have a file with name procs and the following content:
date httpd ps tty ..... how can i recognize which of these names are processes names and print only them My solution is for i in procs do if [ -p $i] echo $i done but is does not work. I would appreciate any help. |
Try using grep (man grep on how to use) for searching the file.
I use the following from the command line to find a set of characters in a file: $ cat <filename> | grep ps |
Something line:
for i in $( cat procs) do if ps -C $i > /dev/null echo $i done |
Quote:
Why do you consider this a solution? What do you think should be happening, what do the man-pages for the programs involved in your "solution" suggest they do, what is the outcome of your attempt? Do your own homework. |
"It's the syntax, stupid!" :)
Seriously, tell me the 3 CLI ways to get documentation on a command, & I will tell you which one to use to solve your problem. Welcome to LQ Welcome to LQ. Yes, I mean it. I know others have been pretty harsh on you for posting your homework, but in the process they have provided much amusement for the rest us: Find all threads started by jianelisj Thank you for the wonderful light start to my day. Proves the old adage: "No one is completely worthless -- you can always be used as a horrible example. For the moment, you are the horrible example; however, in amongst negative commentary are the seeds of reform -- re-read & learn. Surprisingly, one thing no one has suggested is Raymond & Moen's "How To Ask Questions the Smart Way" found here or here. (Both of the authors maintain public copies.) Finally, if you would really like to become a valued, contributing member of LQ, consider the following voluntary homework assignment:
|
All times are GMT -5. The time now is 12:08 PM. |