![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Sort files by date, not showing files from today | carlosdivega | UNIX for Dummies Questions & Answers | 3 | 07-17-2008 11:37 AM |
| How to sort a field in a file having date values | risshanth | Shell Programming and Scripting | 4 | 06-04-2008 06:03 AM |
| sort files by date | itik | Linux | 1 | 06-02-2008 07:25 PM |
| loop through the directory for files and sort by date and process the first file | dsdev_123 | AIX | 1 | 01-30-2008 05:31 PM |
| Sort files by Date-timestamps available in filename & pick the sortedfiles one by one | Chindhu | Shell Programming and Scripting | 4 | 08-10-2007 08:54 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
Hi all, I have a pecular issue in sorting these files in Solaris environment. All the below files are modified on November 4th, but I want to sort these files as per date column (eg: 01May07_1623 = ddmmmyy_hhmm) Nov 4 18:27 SONYELEC00.GI22973.01May07_1623.gpg Nov 4 18:27 SONYELEC00.GI22973.06Mar08_1504.gpg Nov 4 18:27 SONYELEC00.GI22973.06Sep07_1900.gpg Nov 4 18:27 SONYELEC00.GI22973.08Nov07_1900.gpg Nov 4 18:27 SONYELEC00.GI22973.13Aug07_1900.gpg Nov 4 18:27 SONYELEC00.GI22973.19Apr07_1733.gpg Nov 4 18:27 SONYELEC00.GI22973.22Jan08_1900.gpg Nov 4 18:27 SONYELEC00.GI22973.24Apr07_1757.gpg Nov 4 18:27 SONYELEC00.GI22973.26Jun08_1900.gpg Nov 4 18:27 SONYELEC00.GI22974.01May07_1623.gpg Nov 4 18:27 SONYELEC00.GI22974.13Aug07_1900.gpg Nov 4 18:27 SONYELEC00.GI22974.19Apr07_1733.gpg Nov 4 18:27 SONYELEC00.GI22974.24Apr07_1757.gpg Appreciate your quick support Thanks, Shiva shivadba@xxxxxx Last edited by DukeNuke2; 11-06-2008 at 01:48 PM.. Reason: deleted mail... |
|
||||
|
below perl may help you some Code:
open FH,"<file";
@arr=<FH>;
close FH;
%hash=('Jan','01','Feb','02','Mar','03','Apr','04','May','05','Jun','06','Jul','07','Aug','08','Sep','09','Oct','10','Nov','11','Dec','12');
foreach(@arr){
@temp=split("[.]",$_);
my $str=buildnum($temp[2]);
$res{$str}=$_;
}
foreach $key (sort keys %res){
print $res{$key};
}
sub buildnum{
my $str1=shift;
$day=substr($str1,0,2);
$mon=$hash{substr($str1,2,3)};
$year="20".substr($str1,5,2);
$time=substr($str1,-4);
return $year.$mon.$day.$time;
}
|
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|