The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Simple Script mojoman Shell Programming and Scripting 6 05-12-2008 12:55 AM
simple script help ali560045 Shell Programming and Scripting 4 01-24-2008 01:24 AM
Simple Script Help Skunkie UNIX for Dummies Questions & Answers 4 10-02-2006 08:18 AM
simple awk script... moxxx68 Shell Programming and Scripting 3 01-24-2005 12:17 AM
simple script hedrict UNIX for Dummies Questions & Answers 4 02-23-2004 12:15 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-22-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 180
simple script

i have a script that check for the last date entry made in a series of files
--------------------------------------------------------------------

a=`date +"%Y-%m-%d"`

for i in *.log*
do
cat $i | grep $a

echo $i >> file1.txt
echo $a >> file1.txt
done
-----------------------------------------------------------------------

but this format of date i,e "a" checks for current/today date .

i want the date that checks the last date put into that files.the format should be same as y-m-d
-----------------------------------------------------------------------
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-22-2008
Registered User
 

Join Date: May 2006
Posts: 43
If you want to select the file which are created in the latest date, you have to do like this :

mon=`ls -lrt | awk '{print $6}' | tail -1`
day=`ls -lrt | awk '{print $7}' | tail -1`

for file in `ls -l | grep "$mon $day" | awk '{print $9}'`
do
echo $file
done
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0