Examples of using the ls command

Examples of using the ls command

1. 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.

2. 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 '*'.

The inode number of each file is also displayed.

3. To list the contents of 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.

4. 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.

5. 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.


Top document