The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-22-2005
abhijeetkul abhijeetkul is offline
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
  #2 (permalink)  
Old 12-22-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0