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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
parse an arpwatch file and retain most recent mac CM64 Shell Programming and Scripting 8 04-12-2007 12:21 AM
Get the most recent file from a remote server anujairaj UNIX for Dummies Questions & Answers 5 09-27-2006 10:31 AM
getting the most recent file anujairaj Shell Programming and Scripting 3 06-22-2006 03:34 PM
Changing name of most recent file warpmail AIX 1 02-15-2006 07:34 PM
Most Recent File script josborn777 Shell Programming and Scripting 1 03-29-2002 05:01 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 08-22-2002
duncan_glover duncan_glover is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 3
reading directory for most recent file?

Dear All,

I'm trying to write a script that searches thru a directory looking for a most recent file and then scp that file.

I have the scp working, but I don't know how to browse the directory and select the most recent file.

The file name includes a date & time stamp (e.g. 20020822112501)

Any ideas?? I'm really stuck with this one, complete novice!
  #2 (permalink)  
Old 08-22-2002
janr janr is offline
Registered User
  
 

Join Date: Jun 2002
Location: Amsterdam (Netherlands)
Posts: 142
Some questions

Are you looking for the file which has the most resent filename?
-- If so you can use the sort command, like `ls -1 | sort`

Are you looking for the file which is most resent touched (writing in the file)?
-- If so you can use the ls command, like `ls -rt1 | tail -1`

take care

JanR
  #3 (permalink)  
Old 08-22-2002
duncan_glover duncan_glover is offline
Registered User
  
 

Join Date: Aug 2002
Posts: 3
Thanks, how do I assign the lastest file to a variable that I can use in a script??
  #4 (permalink)  
Old 08-22-2002
janr janr is offline
Registered User
  
 

Join Date: Jun 2002
Location: Amsterdam (Netherlands)
Posts: 142
e.g.

depends on the shell you use

#!/bin/csh

setenv RESENTFILE `ls -rt1 | tail -1`
echo $RESENTFILE

exit
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:55 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