Long list file display different time format.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Long list file display different time format.
# 1  
Old 01-16-2014
Long list file display different time format.

Hi Gurus,

I have some weird issue. when using
Code:
ls -l

the result shows different time format:
Code:
-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.

how can I fix this issue.

Thanks in advance.
# 2  
Old 01-16-2014
There is nothing to fix; that is the way ls is designed to work. For dates more than six months in the past and for dates in the future, it prints the year. For dates within the past six months, it prints the timestamp.
# 3  
Old 01-16-2014
This is standard ls functionality, older dates need the year and drop time info.

Many ls implementations let you specify your own time style eg:

Code:
$ ls -l --time-style="+%Y/%m/%d %T"
-rw-r--r-- 1 abc    gourp1    3032605576  2013/06/14 19:56:00 abc
-rw-r--r-- 1 abc    gourp1    1689948832  2013/08/10 06:22:13 def


Last edited by Chubler_XL; 01-16-2014 at 04:20 PM.. Reason: Added example output
This User Gave Thanks to Chubler_XL For This Post:
# 4  
Old 01-16-2014
We discussed similar topic in your previous thread

You can use:
Code:
Option  Format
------  ---------------------------------
-e      mmm dd hh:mm:ss yyyy
-E      yyyy-mm-dd hh:mm:ss.nnnnnnnnn

E.g.
Code:
$ ls -e file
-rw-r--r--   1 yoda yoda 19 Nov 12 08:29:56 2013 file
$ ls -E file
-rw-r--r--   1 yoda yoda 19 2013-11-12 08:29:56.000000000 -0800 file

These 2 Users Gave Thanks to Yoda For This Post:
# 5  
Old 01-16-2014
Quote:
Originally Posted by Chubler_XL
This is standard ls functionality, older dates need the year and drop time info.

Many ls implementations let you specify your own time style eg:

Code:
$ ls -l --time-style="+%Y/%m/%d %T"
-rw-r--r-- 1 abc    gourp1    3032605576  2013/06/14 19:56:00 abc
-rw-r--r-- 1 abc    gourp1    1689948832  2013/08/10 06:22:13 def

Thank you very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transfer file from a server takes long time

It takes 6 hrs for a 90 GB zip file that i am copying / transferring from serverA onto serverB. scp user1@serverA:/opt/setup/cash.zip . Output: cash.zip 21% 19GB 4.7MB/s 4:11:46 ETA uname -a SunOS serverB 5.11 11.2 sun4v sparc sun4vCan you please suggest if i could do... (11 Replies)
Discussion started by: mohtashims
11 Replies

2. 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

3. UNIX for Dummies Questions & Answers

ls is taking long time to list

Hi, All the data are kept on Netapp using NFS. some directories are so fast when doing ls but few of them are slow. After doing few times, it becomes fast. Then again after few minutes, it becomes slow again. Can you advise what's going on? This one directory I am very interested is giving... (3 Replies)
Discussion started by: samnyc
3 Replies

4. UNIX for Dummies Questions & Answers

Script to display lines in a file in a particular format

I have a bunch of files in various folders. I want to go through each of them and display certain lines in a particular format All files have a similar format Date: Time: User: Message: Miscellaneous: (and some other stuff)I want to display to only the "Date:", "Time:" "User:" lines in... (7 Replies)
Discussion started by: newbiegal01
7 Replies

5. Shell Programming and Scripting

Help with cat long list of file

I have long list of input file's content that I plan to "cat" all of the content into another output file. The total input file is around 20,000 which all named with ".txt" Below is the command that I try: cat *.txt > all_file.out -bash: /usr/bin/sudo: Cannot allocate memory Unfortunately,... (2 Replies)
Discussion started by: perl_beginner
2 Replies

6. UNIX for Dummies Questions & Answers

gref -f taking long time for big file

grep -f taking long time to compare for big files, any alternate for fast check I am using grep -f file1 file2 to check - to ckeck dups/common rows prsents. But my files contains file1 contains 5gb and file 2 contains 50 mb and its taking such a long time to compare the files. Do we have any... (10 Replies)
Discussion started by: gkskumar
10 Replies

7. Shell Programming and Scripting

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! (16 Replies)
Discussion started by: Deanne
16 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Changing display and format of file

I have an input file which looks like this: 601 a 602 a 603 a 601 b 610 c 615 c 603 d 601 d 612 d I need the utput to look like this 601 a 602 603 602 a 601 603 603 a 601 602 601 b 610 c 615 615 c 610 603 d 601 612 (1 Reply)
Discussion started by: wahi80
1 Replies

10. Shell Programming and Scripting

Help with find command and list in a long format each found file

The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory. The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a... (5 Replies)
Discussion started by: alexcol
5 Replies
Login or Register to Ask a Question