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
Simple Script mojoman Shell Programming and Scripting 6 05-12-2008 03:55 AM
simple script help ali560045 Shell Programming and Scripting 4 01-24-2008 05:24 AM
Simple Script Help Skunkie UNIX for Dummies Questions & Answers 4 10-02-2006 11:18 AM
simple awk script... moxxx68 Shell Programming and Scripting 3 01-24-2005 04:17 AM
simple script hedrict UNIX for Dummies Questions & Answers 4 02-23-2004 04:15 PM

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

Join Date: Oct 2007
Posts: 328
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
-----------------------------------------------------------------------
  #2 (permalink)  
Old 01-22-2008
ThobiasVakayil ThobiasVakayil is offline
Registered User
  
 

Join Date: May 2006
Posts: 64
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
Sponsored Links
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 01:56 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