The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep using date format ali560045 Shell Programming and Scripting 8 12-11-2007 06:39 PM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 08:42 PM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-28-2006 12:30 AM
Date format: Khoomfire UNIX for Advanced & Expert Users 1 02-13-2006 09:44 AM
date format big123456 Shell Programming and Scripting 2 07-22-2005 05:57 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-24-2007
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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
  #2 (permalink)  
Old 12-24-2007
fazliturk fazliturk is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 45
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 (permalink)  
Old 12-24-2007
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,927
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 }
and then replace your loop with

Code:
ps -aef | awk -f date.awk >> dates
  #4 (permalink)  
Old 12-26-2007
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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 (permalink)  
Old 12-26-2007
fazliturk fazliturk is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 45
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0