The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sorting Files by date and moving files in date order rebel64 Shell Programming and Scripting 2 03-11-2008 08:45 AM
Create a list of files that were modified after a given date. rkka UNIX for Dummies Questions & Answers 4 01-22-2008 01:12 AM
How do I organize a series of files in date order? hedgehog001 UNIX for Dummies Questions & Answers 1 08-22-2005 08:04 PM
list of files in date order Jeannine UNIX for Dummies Questions & Answers 2 08-15-2005 11:19 AM
retain create/mod date and time of files jerardfjay Shell Programming and Scripting 5 06-15-2005 11:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-15-2006
Registered User
 

Join Date: May 2006
Posts: 12
Stumble this Post!
Order files by create date

hi
Is there a way to sort files in the order they were created ,and move them to another directory one by one ,oldest being the first to be moved.
Thanks
Arif
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-15-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 371
Stumble this Post!
Code:
ls -tr|xargs -i ksh -c "mv {} ../tmp/"
Cheers
Reply With Quote
  #3 (permalink)  
Old 05-15-2006
Registered User
 

Join Date: May 2006
Posts: 12
Stumble this Post!
Hi thanks for reply
I have like 5 files(*.txt) in the directory
I want to move only the oldest file in the order of creation to another directory .
I am trying to use
mv (ls -tr *.event |head -1) /arif/temp/ in bash shell
I need help to correct the syntax of this command if my idea is right .

Last edited by mab_arif16; 05-15-2006 at 09:57 AM.
Reply With Quote
  #4 (permalink)  
Old 05-15-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 371
Stumble this Post!
Ok ,use:
Code:
ls -tr *.txt|head -1|xargs -i ksh -c "mv {} ../tmp/"
Reply With Quote
  #5 (permalink)  
Old 05-15-2006
Registered User
 

Join Date: May 2006
Posts: 12
Stumble this Post!
Thanks that was perfect
Arif
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0