Order files by create date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Order files by create date
# 1  
Old 05-15-2006
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
# 2  
Old 05-15-2006
Code:
ls -tr|xargs -i ksh -c "mv {} ../tmp/"

Cheers
# 3  
Old 05-15-2006
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 01:57 PM..
# 4  
Old 05-15-2006
Ok ,use:
Code:
ls -tr *.txt|head -1|xargs -i ksh -c "mv {} ../tmp/"

# 5  
Old 05-15-2006
Thanks that was perfect
Arif
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Copy files in order of creation date

Hi everyone :-) I ran into a small issue. I would like to copy some files in the precise order they were created. So the oldest files should be copied first and the newest ones last. I tried cp -r $(ls -1t) ./destination but the files are still not sorted properly. I was thinking, that... (11 Replies)
Discussion started by: officiallyme
11 Replies

2. UNIX for Beginners Questions & Answers

How to create a summary file of all files in a directory sorted in reverse alphabetical order.?

I have an interactive script which works terrific at processing a folder of unsorted files into new directories. I am wondering how I could modify my script so that( upon execution) it provides an additional labelled summary file on my desktop that lists all of the files in each directory that... (4 Replies)
Discussion started by: Braveheart
4 Replies

3. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

4. UNIX for Dummies Questions & Answers

Column to row - in order to create zones

i need a script that reads a wwn file like this: LOCAL_HOST (before) 50:01:24:82:00:6c:a9:04 21:00:00:24:ff:30:35:7b 21:00:00:24:ff:30:35:70and will run over the file with all the wwn's in the same row in order to create zones on a switch like so: LOCAL_HOST (after) zonecreate " (... (2 Replies)
Discussion started by: boaz733
2 Replies

5. UNIX for Dummies Questions & Answers

Renaming files by changing date order

I'm looking for a simple solution to rename a batch of files. All of the files in this directory start with a date in the format mm.dd.yy followed by a space and then additional descriptive text. Example: 01.21.10 742 P.xlsx 02.24.09 730 Smith.xlsx The information following the date can... (3 Replies)
Discussion started by: kreisel
3 Replies

6. Shell Programming and Scripting

Sorting Files by date and moving files in date order

I need to build a k shell script that will sort files in a directory where files appear like this "XXXX_2008021213.DAT. I need to sort by date in the filename and then move files by individual date to a working folder. concatenate the files in the working folder then start a process once... (2 Replies)
Discussion started by: rebel64
2 Replies

7. UNIX for Dummies Questions & Answers

Create a list of files that were modified after a given date.

Hello Mates! I'm kinda new to unix and need to a solve a problem. Input: date Situation: With the given date I need to find a list of all such files starting from a given path that were modified after the given date. I experimented with the "find" with "-newer" but did not quite get it... (4 Replies)
Discussion started by: rkka
4 Replies

8. UNIX for Dummies Questions & Answers

How do I organize a series of files in date order?

I'd like to ls a group of files in date order but I'm not sure what the commands would be. Can anyone help with this? (1 Reply)
Discussion started by: hedgehog001
1 Replies

9. UNIX for Dummies Questions & Answers

list of files in date order

Im on HP/UX and am trying to find the command like an ll but that will sort showing the most currently modified programs first. Can anyone help me with that? :cool: (2 Replies)
Discussion started by: Jeannine
2 Replies

10. Shell Programming and Scripting

retain create/mod date and time of files

Hi, I have a requirement by which I need to take a snapshot of a certain directory of a certain types of files into a target directory within the same server (HP-UX 9000). The problem is that the files created in the target directory has the date and time of when the files were copied over. ... (5 Replies)
Discussion started by: jerardfjay
5 Replies
Login or Register to Ask a Question