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
get latest file inquirer Shell Programming and Scripting 4 04-02-2009 11:15 AM
Script to pick out files from a file which are older than 15 days viv1 Shell Programming and Scripting 1 04-02-2008 09:42 AM
Getting latest file from ftp arunavlp UNIX for Dummies Questions & Answers 3 02-08-2008 10:19 AM
get latest file via ftp command alx Post Here to Contact Site Administrators and Moderators 2 01-26-2006 11:44 AM
want to cat the latest log file created vkandati UNIX for Dummies Questions & Answers 1 03-08-2005 06:13 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 04-04-2008
mail2sant mail2sant is offline
Registered User
  
 

Join Date: Apr 2008
Location: bangalore
Posts: 67
how can i pick the latest log file as per below

in the below .. i want to pick the latest logfile which is having JPS.PR inside..

that means i want particularly "spgport040408041223.log:@@@@@@@@ 04:13:09 Adding: JPS.PR."
which is latest among these..
is it possible to compare the current time with logfile time ?


reptm@xblr0758rop> grep -i adding spg* | grep JPS.PR | grep -iv equation
spgport040108014525.log:@@@@@@@@ 01:46:17 Adding: JPS.PR.
spgport040108014824.log:@@@@@@@@ 01:49:14 Adding: JPS.PR.
spgport040108021914.log:@@@@@@@@ 02:20:09 Adding: JPS.PR.
spgport040108022211.log:@@@@@@@@ 02:23:03 Adding: JPS.PR.
spgport040108022658.log:@@@@@@@@ 02:27:52 Adding: JPS.PR.
spgport040108023238.log:@@@@@@@@ 02:33:30 Adding: JPS.PR.
spgport040108024642.log:@@@@@@@@ 02:47:32 Adding: JPS.PR.
spgport040108024908.log:@@@@@@@@ 02:50:00 Adding: JPS.PR.
spgport040108025235.log:@@@@@@@@ 02:53:25 Adding: JPS.PR.
spgport040108030449.log:@@@@@@@@ 03:05:39 Adding: JPS.PR.
spgport040108031557.log:@@@@@@@@ 03:16:48 Adding: JPS.PR.
spgport040108041535.log:@@@@@@@@ 04:16:25 Adding: JPS.PR.
spgport040408041223.log:@@@@@@@@ 04:13:09 Adding: JPS.PR.
  #2 (permalink)  
Old 04-05-2008
helper helper is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 25
Arrow Just use tail command with your command

If your command

grep -i adding spg* | grep JPS.PR | grep -iv equation

is fetching the right set of file and if its just a matter of picking up the latest file then use tail -1 with your command ...


the command will be
grep -i adding spg* | grep JPS.PR | grep -iv equation | tail -1


I think this must work.....
  #3 (permalink)  
Old 04-02-2009
vpraveena vpraveena is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
Command we tried using to grep ERROR from lastest 1 log files from 5 logs files available in that particular directory is:
grep ERROR 'ls -ltr | tail -1'

but this command is not working.. for me its saying.. cannot open DistributeImageFilesToTarget_10_dataLocations_PhillipinesDataLocations.xml.log

if i give ls -lrt for all the files in that diretory

-------r-- 1 egdevbb intdev 5022 Apr 2 05:13 DistributeDataFilesToTarget_4_dataLocations_ChinaDataLocations.xml.log
-------r-- 1 egdevbb intdev 1672 Apr 2 05:14 DistributeImageFilesToTarget_14_dataLocations_WHQDataLocations.xml.log
-------r-- 1 egdevbb intdev 7480 Apr 2 05:15 DistributeImageFilesToTarget_60_dataLocations_IndonesiaDataLocations.xml.log
-------r-- 1 egdevbb intdev 2113 Apr 2 05:34 DistributeImageFilesToTarget_8_dataLocations_MalaysiaDataLocations.xml.log
-------r-- 1 egdevbb intdev 2107 Apr 2 05:39 DistributeImageFilesToTarget_10_dataLocations_PhillipinesDataLocations.xml.log
  #4 (permalink)  
Old 04-04-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,163
Try "ls -1tr" in place of "ls -ltr". The parameter "-1" (-one) just displays the filename as distinct from "-l" (-ell) which gives more detail and confuses your script.
  #5 (permalink)  
Old 04-05-2009
septima.pars's Avatar
septima.pars septima.pars is offline
Registered User
  
 

Join Date: Jan 2009
Location: Chicago
Posts: 31
Quote:
Originally Posted by methyl View Post
Try "ls -1tr" in place of "ls -ltr". The parameter "-1" (-one) just displays the filename as distinct from "-l" (-ell) which gives more detail and confuses your script.
Thank you for that insight!
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 04: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