Examples of using the ls command

To list the contents of the current directory:

   ls
   README        bago.hlp      helpex.hlp   hyperhelp
   app-defaults  helpex        hoh.hlp

This lists the contents of the current directory. File and directory names are listed in columns in alphabetical order.


To list each file's type and inode number:

   ls -Fi
     6752 Mail/         102574 SGML/         147215 UNIX_tips/
   172802 Xapps/         51200 bin/           44801 dead.letter
    44802 mbox           44809 test*         102733 tmp/

This lists the contents of the current directory. Directories are shown with a trailing '/'; files which have access permissions that allow the file to be executed are shown with a trailing '*'.


To list the contents of a directory using wildcard characters:

   ls *.txt
   udi1.txt           wais_x500_www.txt

This lists each file in the current directory which has the filename extension *.txt.


To list files in another directory:

   ls ../Mail

This lists the contents of the directory Mail which is at the same level in the directory hierarchy as the current directory.


To list each subdirectory and its contents, repeating this recursion:

   ls -R uunet
   MetaCard    README      README.ftp

   uunet/MetaCard:
   BLURB.txt  BUGS.txt   FAQ.txt    README.mc  metacard

   uunet/MetaCard/metacard:
   Makefile      XCmdGlue.c    XTtemplate.c  XtTemplate.c  mc       mchelp
   README.ext    XCmdGlue.h    XtGlue.c      external.c    mcXThelp mchome
   XCmdFuncs.c   XCmdNames.h   XtGlue.h      external.h    mcdemo   mctools

This will recursively list the contents of each subdirectory there is below the directory uunet.


[Home] [Search] [Index] This site maintained by system@gantep.edu.tr