Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ls with timestamp 1

Status
Not open for further replies.

comgrit

MIS
Dec 24, 2002
22
TH
I'm trying to extract the filename and date/time stamp of each file in YYYYMMDDHHMMSS format. For example

$ ls -l
total 26
-rw-rw-r-- 1 idwcq idwcq 0 Jun 3 13:30 os30_mdai_fw.stopfw
drwxrwxrwx 2 idwcq idwcq 1024 May 14 23:58 temp
drwxrwxrwx 2 idwcq idwcq 3072 Mar 3 05:50 test
drwxrwxrwx 2 idwcq idwcq 1024 Jun 2 13:03 work
drwxrwxrwx 3 idwcq idwcq 8192 Jun 2 13:02 zip_arch

What I need is just like this :
20030603133000 os30_mdai_fw.stopfw
20030514235800 temp
20030303055000 test
20030602130300 work
20030602130200 zip_arch

Any suggestion ? Thanks in advance
 
This will get you started:

ls -al --full-time | awk '{print $10$8$7$9, $11}'| sed 's!:!!g'

Gets you this ........

200304Jun143140 .
200322Apr073909 ..
200303Jun131446 .bash_history
200322Apr073909 .bash_logout
200322Apr073909 .bash_profile
200322Apr073909 .bashrc
200304May211450 ben1
200304May211527 ben2
200327May210441 bob.txt
200322Apr073909 Desktop
200322Apr073909 .emacs
200304May210950 fred


You then need to play with the Month to convert it to numeric .... we can do this with a pipe to sed -e ... but I gota go off for a bit, back soon ...

Ok like this:

ls -al --full-time | awk '{print $10$8$7$9, $11}'| sed -e's!:!!g' -e 's!May!05!g' -e 's!Jun!06!g'


20030406143140 .
200322Apr073909 ..
20030306131446 .bash_history
200322Apr073909 .bash_logout
200322Apr073909 .bash_profile
200322Apr073909 .bashrc
20030405211450 ben1
20030405211527 ben2
20032705210441 bob.txt
200322Apr073909 Desktop
200322Apr073909 .emacs
20030405210950 fred


Realy must go ....

Good Luck
 
Thank you very much. This is really help as to get me starts. I can take care of the rest.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top