Sorting Files by date and moving files in date order


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sorting Files by date and moving files in date order
# 1  
Old 03-10-2008
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 process is finish then increment by +1 and move the next date to the working folder. Using a AIX box but shortly will be switching to Linux
# 2  
Old 03-11-2008
Show your code.
# 3  
Old 03-11-2008
Bug sort by date

You can use sort -k1.??(starting field no),ending filed no.
say for example for your date XXXX_2008021213.DAT to sort this on year
mth and date order you can use
sort -k1.6,1.9 -k1.10,1.11 -k1.12,1.13 input_file > output file
Cheer up
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 Dummies Questions & Answers

Script moving files based on date

Hi, I need a script that moves files based on date to a folder. The folder should be created based on file date. Example is : Date file name ----- -------- Oct 08 07:39 10112012_073952.xls Oct 09 07:39 10112012_073952.xls Oct 10 07:39 ... (6 Replies)
Discussion started by: rockingvj
6 Replies

3. Shell Programming and Scripting

Moving files to different date files

I have files as below I need to have all the files renamed as below There are 100 of files like this. How can I do this? (3 Replies)
Discussion started by: dsravan
3 Replies

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

5. UNIX for Advanced & Expert Users

Help with sorting files according to modification date

Hi, I was very surprised to not be able to find an answer to this question despite my best efforts in Google and elsewhere. Maybe it's a good thing as it forced me to finally become a member in this great forum that i use frequently. Ok my question: I want to be able to sort files inside a... (3 Replies)
Discussion started by: stavros
3 Replies

6. Shell Programming and Scripting

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 (4 Replies)
Discussion started by: mab_arif16
4 Replies

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

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

9. UNIX for Dummies Questions & Answers

Moving Files within a particular date range

Hi, Can someone please help me with this. Actually i want to move files from one directory to another directory , But I just want to move files of a specific data range. For ex: This is my directory which contains all fine. /home/Rooh Then there is a long listing of files. suppose this... (3 Replies)
Discussion started by: rooh
3 Replies

10. UNIX for Dummies Questions & Answers

Moving files based on creation date

Howdy, I'm trying to figure out how to move multiple files based on their creation date. If anyone can enlighten me it would be most appreciated!! Thanks! :D (1 Reply)
Discussion started by: dgoyea
1 Replies
Login or Register to Ask a Question