iLTC Home
Bookmark iLTC!

Categories

Perl
  • Perl Tutorials Beginners

  • Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

  • HTML
  • HTML Tutorials

  • Command Line
  • Command Line Tutorials

  • How Tos
  • Other Tips and Tricks



  • #!/usr/bin/perl
    2210871

    iLoveTheCode.com

    Command Line - List Directory Contents ls


    To list the current directory's contents, at the prompt, type:

    ls

    Press the "enter" key.

    The prompt in my terminal is "chris$", so the above command looks like this:
    chris$ ls


    If you have a lot of documents, these results display in columns and are not very readable.

    So add the option -l (that's a small letter L) to see more information, neatly in one column, one line per item.

    ls -l

    This will display things such as permissions, owner, group, date, and time for each file and directory contained in the current directory.

    Add other options to view information in different ways...

    ls -lhS

    In this example:
    -the l option lists all the information
    -the h option shows each file's size in K (kilobytes)
    -the S sorts by size

    You could have skipped the h option, but I like seeing my files in K (kilobytes) rather than in B (bytes).


    One of my favorites is ls -lt

    The "t" standing for "time". Hence, this will list your files by time updated.


    Keep in mind, many options will not stand alone.
    Example: The t option needs the l option to display in a list.
    So "ls -t" will not display the files by time, the t will be ignored, and the files will simply display in columns.

    To see all the options available to you, at the prompt, type:

    man ls

    For more about "man" (manual) see COMMAND LINE TIPS below:


    Copy and Paste Command Line Code:

    ls -l
    ls -la
    ls -lh
    ls -lhS
    ls -lt



    COMMAND LINE TIPS:

    To see a list of commands on your Unix or Mac machine, type:

    man builtin
    or
    man cd

    The "enter/return" key or "down arrow" key will page down, and "q" will return you to the prompt.


    To see a list of operands (options/arguments) for a specific command, type:

    man CommandYouWantToKnowAbout

    example:

    man ls





    Resources:
    Command Line Change Directory - Directories cd




    Previous Article: Command Line Change Directory Directories cd
    Next Article: Command Line Change Directory Directories cd






    Search iLTC w/ Google




    Recent Articles

  • HTML Font Code
  • Javascript and CSS - Easy Pop Up Help Balloons
  • Use OnMouseOver in Javascript
  • Use onMouseOut in Javascript
  • Use innerHTML to Change Text on a Page
  • Renaming a File with Perl's RENAME Function
  • PRINT to Browser with document.write Command in Javascript
  • Passing an Argument or Variable to a Javascript
  • Opening an Alert Box in Javascript
  • Opening a REMOTE WINDOW in Javascript
  • OPEN and WRITE a Data File in Perl
  • OPEN and READ a Data File in Perl
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • Javascript Reset Form








  • Perl Programming - Javascript Programming - HTML Code - Mac Unix Command Line - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006-2009 iLoveTheCode.com


    Contact Chris | About this Site


    2210082
    Counter by iLoveTheCode.com


    Last Modified: Saturday, 10-Jan-2009 05:40:24 EST



    Hosted as well :)
    Home-brewed logo - 1997