![]() |
|
|
|
|
|||||||
| 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 |
| date format | ali560045 | Shell Programming and Scripting | 4 | 01-25-2008 04:11 AM |
| Date Format | biju.mp | UNIX for Dummies Questions & Answers | 2 | 12-31-2007 06:56 AM |
| 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 | big123456 | Shell Programming and Scripting | 2 | 07-22-2005 01:57 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
help in date format
i have written a script that will grep all the file that run for the current date
i,e today's date for i in *.log do if a=`date +"%b %d"` then ls -ltr | grep $a | tr -s " " | cut -d " " -f6-9 else echo " " fi done ------------------------------------------------------------------------------ these are the apps -rwxr-xr-x 1 pipe pipe 451 Dec 25 23:54 searchstring -rwxr-xr-x 1 pipe pipe 179 Dec 26 00:38 filesize -rwxr-xr-x 1 pipe pipe 89 Dec 26 01:08 revint -rwxr-xr-x 1 pipe pipe 2126 Jan 9 04:57 wordgame -rw-r--r-- 1 pipe pipe 1871 Jan 9 06:00 sqlnet.log -rwxr-xr-x 1 pipe pipe 791 Jan 10 01:24 apps -rw-r--r-- 1 pipe pipe 1969 Jan 10 01:24 perst -rw-r--r-- 1 pipe pipe 11020 Jan 10 02:45 core -rwxr-xr-x 1 pipe pipe 144 Jan 10 03:07 d1 --------------------------------------------------------------------------------------------------------------- i want my script to grep the file according to the current date that is jan 10.the desired o/p should be Jan 10 01:24 apps Jan 10 01:24 perst Jan 10 02:45 core Jan 10 03:07 d1 --------------------------------------------------------------------- but in this script i cnt grep those files that are running for todays date .its showing me all the file which has benn last modified. i want to grep only those file which has been modified for current date....plz help me in this Last edited by ali560045; 01-10-2008 at 03:19 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
you can use find
Code:
# find . -type f -name "*.log" -mtime -1 -ls |
|
#3
|
||||
|
||||
|
can u please show me the code where to use un my script. actually i m not so aware of unix commands. if u dnt mind can u show me the code
|
|
#4
|
|||
|
|||
|
did you try running the find command? you can use back your method , like cut , to get what you want.
|
|
#5
|
||||
|
||||
|
its not helping.find is not working...............
i know some problem is there in my ls -ltr logic........can u help me.its showing the previous date o/p also that is yesterday 90113 4 -rwxr-xr-x 1 pipe pipe 791 Jan 10 01:24 ./apps 90114 4 -rw-r--r-- 1 pipe pipe 1969 Jan 10 01:24 ./perst 90116 4 -rwxr-xr-x 1 pipe pipe 179 Jan 10 04:24 ./filesize 90118 4 -rwxr-xr-x 1 pipe pipe 2126 Jan 9 04:57 ./wordgame 90120 4 -rw-r--r-- 1 pipe pipe 1871 Jan 9 06:00 ./sqlnet.log 90121 12 -rw-r--r-- 1 pipe pipe 11020 Jan 10 02:45 ./core 90122 4 -rwxr-xr-x 1 pipe pipe 122 Jan 10 04:26 ./d1 Last edited by ali560045; 01-10-2008 at 03:28 AM. |
|
#6
|
|||
|
|||
|
Help in date format
Hi
Try this.... ls -ltr | grep -F "Jan 3" | tr -s " " | cut -d " " -f6-9 Specify the date inside quotes of grep -F. Or a=`date "+%b %e"` ls -ltr | grep -F "$a" | tr -s " " | cut -d " " -f6-9 Last edited by karunakaran; 01-10-2008 at 06:05 AM. Reason: To optimise command |
|||
| Google The UNIX and Linux Forums |