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
How can i extarct the output from a file which has been updated from last half an hou tarundeepdhawan Shell Programming and Scripting 5 06-23-2008 02:50 AM
checking out latest updated file asadlone Shell Programming and Scripting 3 05-08-2008 04:16 AM
/etc/utmp file does not get updated with boot up details jyoti_mil UNIX for Advanced & Expert Users 1 06-11-2007 10:41 AM
which file is updated after modified the crontab entries. krishna176 SUN Solaris 1 03-25-2007 02:42 PM
Creating an updated file dbfree Shell Programming and Scripting 4 09-30-2005 03:23 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-04-2008
callimaco0082 callimaco0082 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
Find last updated file

Hi all,

my problem is teh following:

I need to move a file from a folder to another and I usually do it by the get command but in this case I have a list of file in the source folder and I have to select only the lust updated one.
Ho to do this?

All the files have the same name followed by a timestamp; something like:
aaaaaaaa_20080902.TXT
aaaaaaaa_20080903.TXT
aaaaaaaa_20080904.TXT.

I need to move only the last one.

Thanks to all will help.
  #2 (permalink)  
Old 09-04-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
ls -lrt |tail -1 gives you the file with latest time stamp..
  #3 (permalink)  
Old 09-04-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
One way, assumes the last update was on the timestamp:
Code:
file=$(ls -rt aaaaa*.TXT | tail -1)
mv $file /path/to/new/directory
  #4 (permalink)  
Old 09-04-2008
callimaco0082 callimaco0082 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
Hi,
your posts were very welcome.

The problem has been solved.

Thanks one more time!
  #5 (permalink)  
Old 09-04-2008
callimaco0082 callimaco0082 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
I have anew question;

The file I need to move are on another server; how to do the same operation through ftp connection?

I open the connection with ftp command but ls semms not to work (It says that the file doesn't exist but on the source server I can find id with ls)
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 07:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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