![]() |
|
|
|
|
|||||||
| 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 |
| grep using date format | ali560045 | Shell Programming and Scripting | 8 | 12-11-2007 03:39 PM |
| date issue-find prevoius date in a patricular format | bsandeep_80 | UNIX for Advanced & Expert Users | 3 | 11-15-2007 05:42 PM |
| convert mmddyy date format to ccyyddd format?? | Bhups | Shell Programming and Scripting | 2 | 09-27-2006 08:30 PM |
| Date format: | Khoomfire | UNIX for Advanced & Expert Users | 1 | 02-13-2006 06:44 AM |
| date format | big123456 | Shell Programming and Scripting | 2 | 07-22-2005 01:57 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
grep using date format
i have few persistance apps like below
pipe 1118370 1200312 0 Dec 18 - 192:03 java - _AppName=DBSyncController pipe 2523376 1568906 0 feb 25 - 386:15 java -Xms128m -Xmx1024m -D_AppName=DBMaint com pipe 7462996 2531452 0 march 18 - 23:22 java -D_AppName=Interpolation pipe 3379242 7631092 0 may 18 - 27:50 java -D_AppName=Archiver2 ----------------------------------------------------------------------- i want to grep these apps using the above date format.i have written the script but its showing me todays date as dec 24 #!/bin/ksh if test -f dates then rm dates else echo " " fi for i in DBSyncController DBSyncControllerRerun Archiver1 DBSyncListener Archiver2 Cleaner1 Interpolation do a=0 a=`date +"%h %d"` echo $a "\t" $i >> dates done echo "--------------------------------------------------------------------------------------------------------------------" >> dates for i in DBSyncController DBSyncControllerRerun Archiver1 DBSyncListener Archiver2 Cleaner1 Interpolation do a=0 a=`date +"%h"` ps -aef | grep java | grep "$a" | grep $i >> dates done ---------------------------------------------------------------------- i think some problem in date logic,help me in this |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I didn't Understand what you mean above date format. Do you mean
Mount Day - hour:second. What about the other date format that you don't want to catch in your ps -ef command. Besides that you can not use date in this example date means todays date. if you send your ps -ef command's output which shows the date format that you want to catch and also the ones you dont want to catch together we can find the solution |
|
#3
|
|||
|
|||
|
Your requirements are somewhat unclear. If you want to capture the date in the
format outputted by ps, here is one way of doing it. Create a file (e.g. date.awk) containing the following lines Code:
/java/ && /DBSyncController/ { print $5, $6 }
/java/ && /DBSyncControllerRerun/ { print $5, $6 }
/java/ && /Archiver1/ { print $5, $6 }
/java/ && /DBSyncListener/ { print $5, $6 }
/java/ && /Archiver2/ { print $5, $6 }
/java/ && /Cleaner1/ { print $5, $6 }
/java/ && /Interpolation/ { print $5, $6 }
Code:
ps -aef | awk -f date.awk >> dates |
|
#4
|
||||
|
||||
|
actually wats the date format to be used ,if date is like march 20,feb 12.and like wise
how do u grep this word in below logic a=`date +"%h %d"` |
|
#5
|
|||
|
|||
|
outputs of ps are columns of strings,parameters. You can not use date as you intend, you must use a way like fmurphys. Firts send all or a sample part of output oF ps -ef with no grep " I mean ps -ef " . Point out our underline the lines that you want. After this say what will you do with this output. Then I thing the solution will be simple
|
|||
| Google The UNIX and Linux Forums |