The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-08-2004
Registered User
 

Join Date: Mar 2004
Posts: 2
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!
Reply With Quote
Forum Sponsor
  #2  
Old 03-08-2004
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
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...
Reply With Quote
  #3  
Old 03-08-2004
Registered User
 

Join Date: Mar 2004
Posts: 2
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!
Reply With Quote
  #4  
Old 03-08-2004
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
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,$_;
}
Reply With Quote
  #5  
Old 03-08-2004
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
Quote:
Originally posted by Ygor
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,$_;
}
yogr:

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,$_;
}
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0