- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: convert a file date to MM/DD/YYYY
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2004 06:29 AM
тАО07-07-2004 06:29 AM
Does anyone know of a simple way to convert a FILE DATE from the typical "ls -l" format to MM/DD/YYYY format?
Meaning, instead of something like:
# ls -l
total 0
-rw-r--r-- 1 bpc users 0 Jul 7 14:24 foo1.txt
-rw-r--r-- 1 bpc users 0 Jun 6 13:21 foo2.txt
#
I'd be looking for (time is not significant to me - only date):
# MY_ls.sh
07072004 foo1.txt
06062004 foo2.txt
#
Is there an easy way to script "MY_ls.sh"?
As always, TIA!
Later,
Ben.
chapmanb@saic.com
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2004 06:40 AM
тАО07-07-2004 06:40 AM
Solution$cat myls
#!/opt/perl/bin/perl
$ArgFile=$ARGV[0];
open(CMD,"ls $ArgFile |");
while (
chomp;
$FileName=$_;
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$AccessTime,$ModifTime,$ChangeTime,$blksize,$blocks)=stat($FileName);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($ModifTime);
$year+=1900;
if ($mday < 10) { $mday="0$mday"; }
if ($mon < 10) { $mon="0$mon"; }
print "$mon$mday$year $FileName\n";
}
close(CMD);
$myls -a .
06072004 myls
04132004 touch_amc
06072004 .
06072004 ..
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2004 06:48 AM
тАО07-07-2004 06:48 AM
Re: convert a file date to MM/DD/YYYY
PERFECT! If I could assign 100 points, I would...
Thanks again, Fred!
Later,
Ben.
chapmanb@saic.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2004 06:52 AM
тАО07-07-2004 06:52 AM
Re: convert a file date to MM/DD/YYYY
Use it like this this:
ftime.pl [-a|-c|-m] file1 [file2 ...]
By default, the modification time is used but you can change to access, -a or change,-c times if you wish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2004 07:02 AM
тАО07-07-2004 07:02 AM
Re: convert a file date to MM/DD/YYYY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2004 12:22 AM
тАО07-09-2004 12:22 AM
Re: convert a file date to MM/DD/YYYY
Kudos for spotting that bug - it slipped right past me... Again - thanks for your post. I'm actually going to use a "hybrid" from your code and Fred's code. You guys make my job a lot easier!!!
Have a great weekend.
Later,
Ben.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2004 01:04 AM
тАО07-09-2004 01:04 AM
Re: convert a file date to MM/DD/YYYY
Hope it didn't do any harm,
Fred
"Reality is just a point of view." (P. K. D.)