next up previous
Next: Essential unix commands Up: unixBasics Previous: Shell commands

Subsections

Directory and File Handling

This section describes some of the more important directory and file handling commands.

Basic commands

Homeworks

Specifying multiple filenames

Try

ls /etc/host*

Multiple filenames can be specified using special pattern-matching characters. The rules are:

For example:
  1. ??? matches all three-character filenames.
  2. ?ell? matches any five-character filenames with 'ell' in the middle.
  3. he* matches any filename beginning with 'he'.
  4. [m-z]*[a-l] matches any filename that begins with a letter from 'm' to 'z' and ends in a letter from 'a' to 'l'.
  5. {/usr,}{/bin,/lib}/file expands to /usr/bin/file /usr/lib/file /bin/file and/lib/file.
Note that the UNIX shell performs these expansions (including any filename matching) on a command's arguments before the command is executed.

Exercises:

   $ cd
   $ mkdir fn ; cd fn
      Note: Two commands can be connected with ``;''.
   $ touch hello[1-3] hello12 jello[1357]
      touch makes empty files
   $ ls
   $ ls -l hell*
   $ ls -l *llo1
   $ ls -l hello?
      Note that this expression doesn't include hello12
   $ ls -l [hj]*3


next up previous
Next: Essential unix commands Up: unixBasics Previous: Shell commands
Naoki Takebayashi 2011-09-13