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
need help in sort ali560045 Shell Programming and Scripting 2 12-04-2007 03:38 AM
sort prasathlogu UNIX for Dummies Questions & Answers 1 10-08-2007 03:56 AM
sort help unics Shell Programming and Scripting 14 04-30-2007 04:28 AM
du -h | sort ? fongthai Shell Programming and Scripting 6 11-02-2006 04:59 PM
2nd sort key whatisthis UNIX for Dummies Questions & Answers 1 10-20-2004 07:46 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-21-2005
Registered User
 

Join Date: Oct 2005
Location: Mumbai,India
Posts: 58
Smile How do i sort?

I have 62000 files in a folder.
Starting from May 17 2004 till Dec 21 2005 ,files are present in this folder.

I want sort these files.All 2004 files i want to keep it in a single folder called "2004_XMls" & rest files i.e 2005 files ,i am going to keep them monthwise.

Just grepping "2004" or "2005" is not working & using egrep is hectic task.

How can i separate all 2004 files from this folder?

file format is like this:
May 18 2004 Ordr_100100000197_180504183038_01.xml
.
.
.
Jan 1 2005 Ordr_100100236163_010105125149_01.xml
.
.


any ideas on using "awk with xargs"?

Regards
Abhijeet
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-21-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,317
To get all 2004 files from the ls output, use
Code:
ls -l | awk '/2004/ {print $9}'
This will give you the filenames.

A better way is to use find in coordination with touch. Touch a file that has a date/time stamp of 01 Jan 2005 00:00. Then run a find on the directory to find files that are older than this file. This will give you files of 2004. Then run a find to get files newer than this file. This should give you files as of 2005.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:37 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