LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-04-2013, 11:40 AM   #1
kratos13ec
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Rep: Reputation: 0
Angry File with hour not year


I need help with something.

When I create a file and then list the file appears

-bash-3.2# ll
-rw-r--r-- 102 Nov 16 16:11 2027196-AN.txt
-rw-r--r-- 94 Nov 16 15:55 2027196-EO.txt
-rw-r--r-- 102 Nov 16 17:34 2027216-AN.txt
-rw-r--r-- 94 Nov 16 17:26 2027216-EO.txt

I need instead of the hours appears the year
-bash-3.2#ll
-rw-r--r-- 96 Apr 02 2012 1705148-RN.txt
-rw-r--r-- 92 Apr 03 2012 1705149-RN.txt
-rw-r--r-- 96 Apr 03 2012 1705150-RN.txt

Even when using touch --date "2013-01-01" 2027216-EO.txt still appear the hour not the year.

Im using and application that need that format of output
 
Old 01-04-2013, 11:57 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
From info ls:
Quote:
the default POSIX locale uses a date like `Mar 30 2002' for non-recent timestamps, and a date-without-year and time like `Mar 30 23:45' for recent timestamps. A timestamp is considered to be "recent" if it is less than six months old, and is not dated in the future.
You can change this behaviour by means of the --time-style option, that lets you specify a format like that one of the date command. There is also a --full-time option which is a shortcut for --time-style=full-iso.

If you want to change the default behaviour, you have to set the environment variable TIME_STYLE. For example according to your requirement:
Code:
export TIME_STYLE=+"%b %d %Y"
At this point, ls -l displays the timestamp in the desired format. Hope this helps.
 
1 members found this post helpful.
Old 01-04-2013, 12:41 PM   #3
kratos13ec
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
From info ls:

You can change this behaviour by means of the --time-style option, that lets you specify a format like that one of the date command. There is also a --full-time option which is a shortcut for --time-style=full-iso.

If you want to change the default behaviour, you have to set the environment variable TIME_STYLE. For example according to your requirement:
Code:
export TIME_STYLE=+"%b %d %Y"
At this point, ls -l displays the timestamp in the desired format. Hope this helps.
Thank it work
 
  


Reply

Tags
date, ls


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron job issue - every hour works, but specific hour fails lunarleviathan Linux - Newbie 6 11-20-2009 12:19 AM
how to get create a file with current hour -1 ? jimmyjiang Red Hat 7 02-13-2008 03:30 PM
Aergh. X dies on the hour, every hour l00zer Linux - Software 4 06-07-2005 10:02 PM
change clock from 24 hour to 12 hour in suse 9.2/KDE 3.3 jmlumpkin Linux - Newbie 1 01-22-2005 11:45 PM
cron job to send file via ftp every 1 hour mcalizo Linux - Newbie 1 07-14-2004 03:50 AM


All times are GMT -5. The time now is 02:55 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration