Announcement

Collapse
No announcement yet.

[SOLVED] Changing the timestamp format of the "ls -l" output

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Changing the timestamp format of the "ls -l" output

    I have a weird problem with Kubuntu 8.04. The "ls -l" command outputs the timestamp in the "YYYY-MM-DD hh:mm" format even though the locale is set to en_us.UTF-8.

    Code:
    $ ls -l kdeglobals
    -rw------- 1 dtoyama dtoyama 9538 2008-05-20 17:22 kdeglobals
    Code:
    $ echo $LANG
    en_US.UTF-8
    What should I do to format the timestamp to "May 20 17:22"? I ran "man ls" but couldn't find much help there.

    [EDIT] I have tried "ls -l --time-style=locale", which according to many documents should work, but it did not.
    Thanks!
    Dai
    Registered Linux User: #281828 | Kubuntu User: #22280

    Kubuntu 18.04 LTS
    Dell Precision Workstation T5500 (Xeon @ 2.13GHz x 2 / 12 GB RAM)

    #2
    Re: Changing the timestamp format of the "ls -l" output

    I tried "ls -l --time-style=iso" and it game me "03-20 22:02" as a timestamp. Seems closer to what you're after.

    Comment


      #3
      Re: Changing the timestamp format of the "ls -l" output

      Originally posted by Nate
      I tried "ls -l --time-style=iso" and it game me "03-20 22:02" as a timestamp. Seems closer to what you're after.
      Thanks for the suggestion. It is close, and I might have to live with it. Just for your reference, this is what I want from "ls -l"... taken from my Fedora Core 6 box.

      Code:
      [daihard-x2:/home/dtoyama/priv/docs/work]$ ls -l
      total 1196
      -rw------- 1 dtoyama rds 46592 Oct 12 2005 changelog.doc
      -rw-r--r-- 1 dtoyama rds 743925 Sep 14 2005 coding_guide.pdf
      -rw-r--r-- 1 dtoyama rds 222720 Nov 15 2007 dynroleswitch.doc
      -rwxr-xr-x 1 dtoyama rds 87552 Dec 17 2004 Feature List.doc
      -rw------- 1 dtoyama rds 29696 Dec 17 2004 investigation.doc
      -rw-r--r-- 1 dtoyama rds 16991 Jul 10 2007 lava_tasklist.odt
      -rw-r--r-- 1 dtoyama rds 9316 Jun 14 2007 nis_accounts.odt
      -rw-r--r-- 1 dtoyama rds 13425 Jun 13 2007 nis_setup.odt
      -rw-r--r-- 1 dtoyama rds 20470 May 20 19:39 nis.zip
      Registered Linux User: #281828 | Kubuntu User: #22280

      Kubuntu 18.04 LTS
      Dell Precision Workstation T5500 (Xeon @ 2.13GHz x 2 / 12 GB RAM)

      Comment


        #4
        Re: Changing the timestamp format of the "ls -l" output

        You can use explicit formatting, for example:
        Code:
        ls -l --time-style=+'%b %e %R %Y'
        (and you can create an ls alias for it, if you want to always use the formatting)

        You can take a look at the formatting options with 'man date'

        Comment


          #5
          Re: Changing the timestamp format of the "ls -l" output

          Originally posted by kubicle
          You can use explicit formatting, for example:
          Code:
          ls -l --time-style=+'%b %e %R %Y'
          (and you can create an ls alias for it, if you want to always use the formatting)

          You can take a look at the formatting options with 'man date'
          Thanks! I've been able to modify your code to display the timestamp exactly like "ls -l" does on Red Hat. Here's my version.

          Code:
          ls -l --time-style=+"%b %e %Y$newline%b %e %R"
          $newline is defined in my .bashrc file. This way, the first format will be used (i.e. showing the year) for non-recent files and the second (i.e showing the time) for recent files. I also got help from this site.

          http://www.gnu.org/software/coreutil...imestamps.html

          Thanks again for your great help.

          Dai
          Registered Linux User: #281828 | Kubuntu User: #22280

          Kubuntu 18.04 LTS
          Dell Precision Workstation T5500 (Xeon @ 2.13GHz x 2 / 12 GB RAM)

          Comment


            #6
            Re: [SOLVED] Changing the timestamp format of the "ls -l" output

            Ah, another little tool to add (and I've just done so) to my alias definitions. For me, that would be:
            alias l='ls -l --time-style=+"%b %e %Y"'
            Thank you daihard and kubicle.
            Windows no longer obstructs my view.
            Using Kubuntu Linux since March 23, 2007.
            "It is a capital mistake to theorize before one has data." - Sherlock Holmes

            Comment

            Working...
            X