![]() |
|
|
|
|
|||||||
| 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 |
| joining command results, and substitution | ncatdesigner | Shell Programming and Scripting | 6 | 04-17-2008 08:37 AM |
| My ps -ef|grep command results are chopped off | bsp18974 | UNIX for Dummies Questions & Answers | 1 | 08-14-2007 07:35 AM |
| New iteration of for-loop without incrementing? | jeriryan87 | Shell Programming and Scripting | 0 | 07-02-2007 11:13 AM |
| How to output the results of the AT command - properly! | SpanishPassion | UNIX for Dummies Questions & Answers | 4 | 12-04-2005 07:27 PM |
| renaming variable between iteration | Nicol | Shell Programming and Scripting | 2 | 04-06-2005 05:04 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Iteration through the results from a unix command
Hi,
I am using a command "ps -ef | grep identify" which results more than 1 results. Actually I need to get the time from each of them , compare with the current date and conditionally stop a process. The problem I am facing is to iterate through the results getting from the command. Please Help me regarding this script. Plz let me know if my problem is not clear.... Thanks Devi |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Quote:
If for earleir than today than ps -ef | grep identify | grep 'date eg Jun 11' would give you those processes. If you want to deal with them one at a time and kill them then personally I'd write them to a file, ps -ef | grep identify | grep ' Jun 11' | awk 'print $2' > pid_list.txt then using a for loop or a while loop process each and issue a kill command. |
|
#3
|
|||
|
|||
|
Thanks 4 the response.....Actually using the command " ps -ef | grep identify " gives the following result:
app 18598 17757 0 13:33 pts/1 00:00:00 grep identify mm 34567 67444 1 12:22 pts/1 00:00:00 grep identify I want to get one line at a time and the process further 4 the requirements......using for loop splits this line with the whitespace. Plz help further.... thanks |
|
#4
|
|||
|
|||
|
Code:
ps -ef | grep identify | while read line; do # for example, split on whitespace once we have one line set -- $line case $5 in 13:33) echo "$@";; esac # just as an example done |
|
#5
|
|||
|
|||
|
Thanks...........That solved my problem......
|
|||
| Google The UNIX and Linux Forums |