UNIX Fundamentals

Pathnames

Example Path Description
foo.c The file foo.c is in the current (working) directory.
pgms/foo.c There is a directory within the current directory named pgms, which contains a file named foo.c. (pgms/foo.c is called a relative path)
/home/jruser/pgms/foo.c The full path to the file foo.c based on the root of the file system.

Directory Abbreviations

Abbrevation Meaning
~ Your home (login) directory.
~username The home directory for the user username.
. The working (current) directory.
.. The parent directory of the working directory.
../.. The parent of the parent directory.

Wildcards

Character Meaning
? Match a single character.
* Match zero or more characters.

Here are some examples:

Expression Description
fo?.c Matches fo followed by a single character, followed by .c. Example matches include foa.c, fob.c, foc.c, fo1.c, fo2.c, etc.
foo.* Matches foo. followed by zero or more characters. Example matches include foo.txt, foo.exe, foo., foo.png, etc.

Redirection

Command Effect
command > myfile Redirects the output of command to the file named myfile​ instead of the terminal (standart output). If myfile already exists, its contents will be replaced.
command >> myfile Similar to >, except the output is appended to the current contents of the file myfile.
command < myfile Command receives input from the file myfile instead of the keyboard (standard input).
cmd1 | cmd2 "Pipes" the output of cmd1 to the input of cmd2.
script myfile Logs everything displayed on the terminal to the file myfile. The logging is terminated with exit.