Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-20-2013, 02:14 AM   #1
LQ Newbie
Registered: Feb 2013
Posts: 7

Rep: Reputation: Disabled
Red face How to pick up a file that has been created latest ?

I have a list of files in my directory with the extension *.ksh.ATC.cs . I need to get the last created file of these and copy it to a different location. How can I do this?
Old 02-20-2013, 02:35 AM   #2
Senior Member
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 273Reputation: 273Reputation: 273
Try with:

cp `ls -ltr *.ksh.ATC.cs | tail -1 | awk '{print $9}'` /yournewfolder
3 members found this post helpful.
Old 02-20-2013, 02:42 AM   #3
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,193

Rep: Reputation: 960Reputation: 960Reputation: 960Reputation: 960Reputation: 960Reputation: 960Reputation: 960Reputation: 960
Note: creation time is not stored, if last modification time is okay, use 'ls -1tr | tail -n1'
Old 02-20-2013, 03:51 AM   #4
LQ Newbie
Registered: Feb 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks a ton kooru, it worked!!!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
sort files inside a directory and sub-directories by latest created walidaly Linux - Software 8 07-25-2009 02:45 PM
latest update patch created wifi connection problems mel1000 Linux - Newbie 1 04-17-2009 10:57 AM
how to pick random file name from a list of filenames in a text file. pdklinux79 Linux - Newbie 9 06-20-2008 02:46 PM
I need to pick out the first, last and how many from a file...?!!? vous Programming 3 03-22-2005 01:44 PM
How to pick a string from a text file? sdandeker Linux - General 1 02-12-2004 04:17 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration