Visit Our UNIX and Linux User Community


List files and display last modify time in a particular format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List files and display last modify time in a particular format
# 1  
Old 01-06-2010
List files and display last modify time in a particular format

hi everyone,

can someone suggest how i can list the contents of a directory and display their corresponding last modify time in the format yyyymmddhhmm?

thanks in advance!
# 2  
Old 01-06-2010

If you have GNU ls:
Code:
ls -l --time-style="+%Y%m%d%H%M"

# 3  
Old 01-06-2010
^thanks, but im using csh on solaris...
# 4  
Old 01-06-2010
Quote:
Originally Posted by Deanne
^thanks, but im using csh on solaris...

It doesn't matter what shell you are using if you have the GNU version of ls. (I believe it is often installed on solaris; it certainly can be.)
# 5  
Old 01-06-2010
^ I don't have GNU.
# 6  
Old 01-06-2010
Hello Deanne,

You most likely would be having perl .
try this.
Code:
ls -l dir | perl -wln -e 'split(/\s+/);@f1=split("-",$_[5]),@f2=split(":",$_[6]);print @f1,@f2'

where dir is the directory containing the files.

Regards.
# 7  
Old 01-09-2010
hi gaurav, thanks.
i tried your code and the following is what the shell returns:

Use of implicit split to @_ is deprecated at -e line 1.
Use of uninitialized value in split at -e line 1, <> line 1.
Use of uninitialized value in split at -e line 1, <> line 1.

Apr1
Jan22
Jan6
Jan5
Jan5
Jan5
Mar14
Jan5
Jan5
Jun30
Aug22
Apr2
Apr1
Nov4

Hmmm, sorry im perl clueless. please help.
thanks in advance.

Previous Thread | Next Thread
Test Your Knowledge in Computers #192
Difficulty: Medium
Hello World in Python looks like this: printLine('Hello, world!')
True or False?

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Display time in 12 hr format

Write a script named time that displays the time in standard 12-hour format, rather than 24-hour format. Allow the user to give a -m option to get 24-hour format. For example: > date Sun Feb 10 10:56:50 CST 2008 > time 10:56 AM > date Sun Feb 10 21:57:07 CST 2008 > time 9:57 PM >... (0 Replies)
Discussion started by: satish24
0 Replies

2. Shell Programming and Scripting

Long list file display different time format.

Hi Gurus, I have some weird issue. when using ls -l the result shows different time format: -rw-r--r-- 1 abc gourp1 3032605576 Jun 14 2013 abc -rw-rw-r-- 1 abc gourp1 1689948832 Aug 10 06:22 abc one display 2013 which is year; another one displays 06:22 which is time. ... (4 Replies)
Discussion started by: ken6503
4 Replies

3. Shell Programming and Scripting

Help to modify in Excel format

Hi I ran some query in solaris machine and the result of the query is as below. Result: dn: uid=xxx,dc=example,dc=com id: xxx firstname: sam lastname: nam But my question is , how to get result in excel format in solaris and result attributes dn,id,firstname,lastname values ... (1 Reply)
Discussion started by: buzzme
1 Replies

4. Shell Programming and Scripting

Display files created on particular date & time

Hi , I have BASH system & i am trying to display the files created on a particular date and time, and after displaying those files I also want to delete all those files.Can anyone of you help me out for this............. Thanx Original post contents restored... Please do not erase the question... (3 Replies)
Discussion started by: rakeshtomar82
3 Replies

5. Shell Programming and Scripting

Modify different files at the same time

Hi, I'm having the following problem. I have some files to modify, between a large number of files. I thought the following code aux2=`grep -l 2.2.17 *` print "$aux2" aux3=`ls -l *.ksh | wc -l` print "$aux3" while ; do print "The counter is $aux3" #Add the sed here ... (3 Replies)
Discussion started by: radicaled
3 Replies

6. Shell Programming and Scripting

modify a format

Hi I have a format that looks like this: #TailType TwoSided #Scale to target True #Target Intensity 100 #Intensities PM/MM #Treatment CEL ./G.CEL #Control CEL ./F.CEL chr1 16 0 chr1 24 0 chr1 32 0.187188 chr1 40 0.14595 chr1 ... (5 Replies)
Discussion started by: kylle345
5 Replies

7. Shell Programming and Scripting

how to format a list of files from ls?

Hi, I have am looking for advice on how to format a directory listing... Basically, I have a list of speech voices at /System/Library/speech/voices This directory looks like: Agnes.SpeechVoice Albert.SpeechVoice Alex.SpeechVoice .. etc I would like to print these out by splitting by... (6 Replies)
Discussion started by: patrick99e99
6 Replies

8. UNIX for Dummies Questions & Answers

Find files and display only directory list containing those files

I have a directory (and many sub dirs beneath) on AIX system, containing thousands of file. I'm looking to get a list of all directory containing "*.pdf" file. I know basic syntax of find command, but it gives me list of all pdf files, which numbers in thousands. All I need to know is, which... (4 Replies)
Discussion started by: r7p
4 Replies

9. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

10. Shell Programming and Scripting

Need year to display from ftped files list

Hi All, p_ftp=dummy time ftp -niv 192.0.0.2 << EOF user dummy dummy cd prt/$p_ftp ascii ls -ltr quit output is -rw-r--r-- 1 500 500 5137 Mar 04 11:21 dummy.csv can any one suggest how to get year while using ftp (1 Reply)
Discussion started by: Vrgurav
1 Replies

Featured Tech Videos