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
Appending date to filename aemunathan Shell Programming and Scripting 5 05-12-2008 08:21 AM
Display filename and wc stats asianmike UNIX for Dummies Questions & Answers 1 04-12-2006 05:51 PM
Append date to filename hshapiro UNIX for Dummies Questions & Answers 5 04-03-2006 10:52 AM
filename to contain date rkap Shell Programming and Scripting 4 04-06-2005 09:53 AM
Add date to a filename richard1975 UNIX for Dummies Questions & Answers 3 02-08-2005 01:37 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-28-2008
pstanand pstanand is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 10
display filename with date

Hi buddies,
I have a doubt. I want to display filename with date in the following format.Is there any way to do this. Kindly give me the solution.

I want to display the result in the following manner.
test1.txt 03/28/2008
testlog.log 02/20/2008

Please let me know one solution how to do this.

Thanks in advance
pstanand
  #2 (permalink)  
Old 03-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Your ls may have localization support which would basically mean if you can find a locale for which this (I would say zany but I'm suppressing it ... oops) date format is standard, that should do it.

Or, you could do something like this:

Code:
perl -e 'for $file (@ARGV) {
    @s = stat $file;
    @d = localtime($s[9]);  # or gmtime; stat[9] is mtime
    printf "$file %02i/%02i/%04i\n", $d[4]+1, $d[3], $d[5]+1900 }' list of files here
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 04: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