![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help Required: Command to find IP address and command executed of a user | loggedout | Security | 2 | 08-06-2008 05:12 PM |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 03:06 PM |
| inconsistent ls command display at the command prompt & running as a cron job | rajranibl | Linux | 5 | 07-30-2007 05:26 AM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | HP-UX | 1 | 10-16-2006 01:16 PM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | Shell Programming and Scripting | 0 | 09-19-2006 06:44 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ls command
Could anyone please tell me how to show a directory listing on aix of recent and ancient files with the same date format, e.g.
file day month year time I know over 6 months or so the time changes to the year, but I need all to be the same. Please help! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Read through this thread concerning a similar problem.
See if RTM's suggestions about installing the gnu version of the "ls" command work for you... |
|
#3
|
|||
|
|||
|
Yep, read about the gnu option ls -T which would do the trick, except I am not allowed to install any utilities on the work system! Gotta do it on my own!
|
|
#4
|
||||
|
||||
|
Perhaps try this perl script instead of ls ...
Code:
#!/usr/bin/perl
foreach (@ARGV) {
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)=stat;
($ss,$mm,$hh,$DD,$MM,$YY)=localtime($mtime);
printf "%04d-%02d-%02d %02d:%02d %s\n",$YY+1900,$MM+1,$DD,$hh,$mm,$_;
}
|
|
#5
|
|||
|
|||
|
Quote:
2 points to make your working perl script a bit safer. 1) always use the warnings switch. #!/usr/bin/perl -w 2) no need to define a bunch of variables you are not going to use. Try: $mtime=(stat($_))[9]; 3) use strict; #when defineing variables its a bad habit to get into of not useing it. one i offten fall prey too. Code:
#!/usr/bin/perl -w
use strict;
foreach (@ARGV) {
my $mtime=(stat($_))[9];
my ($ss,$mm,$hh,$DD,$MM,$YY)=localtime($mtime);
printf "%04d-%02d-%02d %02d:%02d %s\n",$YY+1900,$MM+1,$DD,$hh,$mm,$_;
}
|
|||
| Google The UNIX and Linux Forums |