ls - ltr with Heading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AdusumalliGopikumar
    New Member
    • Aug 2007
    • 42

    ls - ltr with Heading

    Can any one tell me how to get the column heading when we type 'ls -ltr ' to list the files in a particular directory..



    Thanks in advance
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    As far as I know...it is impossible to print the column headers with ls itself..
    May be some other soul can help you out in this forum

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      If you are looking for some kind of header that tells you what each section of the ls -lrt output is, then you are just going to have to keep a print out of it next to you. Its not hard to know what is what. You shouldn't need it if you know what is being output to the screen.

      Regards,

      Jeff

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        I might be misinterpreting your question, but if you just want to print the first line of the output, use this:
        Code:
        ls -ltr | head -n 1
        Greetings,
        Nepomuk

        Comment

        • AdusumalliGopikumar
          New Member
          • Aug 2007
          • 42

          #5
          Originally posted by Nepomuk
          I might be misinterpreting your question, but if you just want to print the first line of the output, use this:
          Code:
          ls -ltr | head -n 1
          Greetings,
          Nepomuk

          No it is giving me a total.

          Comment

          • Nepomuk
            Recognized Expert Specialist
            • Aug 2007
            • 3111

            #6
            Originally posted by AdusumalliGopik umar
            No it is giving me a total.
            Well, that would be the first line of the output. ^^

            Greetings,
            Nepomuk

            Comment

            • AdusumalliGopikumar
              New Member
              • Aug 2007
              • 42

              #7
              Originally posted by Nepomuk
              Well, that would be the first line of the output. ^^

              Greetings,
              Nepomuk

              That is ok Nepomuk, ls -ltr | head -n 10 will 10 lines ...

              but my concern is headings of the columns for 'ls -ltr' ..
              like
              permissions filename size .. etc

              Comment

              • Nepomuk
                Recognized Expert Specialist
                • Aug 2007
                • 3111

                #8
                Originally posted by AdusumalliGopik umar
                That is ok Nepomuk, ls -ltr | head -n 10 will 10 lines ...
                I know, I do understand what head does, I just didn't quite understand, what it was you wanted.
                Originally posted by AdusumalliGopik umar
                but my concern is headings of the columns for 'ls -ltr' ..
                like
                permissions filename size .. etc
                Ah, now I understand. Well, I checked the man page and couldn't find anything. There might be something in the coreutils info page (info coreutils -> * Directory listing:: -> * ls invocation::), but I couldn't find anything to solve your problem in there either so far. I guess, you're probably out of luck.

                Of course, you could always try to write something like that yourself. (Maybe Perl or Python would be a good choice for this? But I know neither...)

                Greetings,
                Nepomuk

                Comment

                • numberwhun
                  Recognized Expert Moderator Specialist
                  • May 2007
                  • 3467

                  #9
                  That I know of, ls does not output the columns at all. 99.9% of the people using unix just know what each column is, so there is no need. If you need to know, then reference the ls man page. Otherwise, you can write a perl script to output headers and then the ls output.

                  Regards,

                  Jeff

                  Comment

                  Working...