next up previous
Next: Listing the Contents of Up: USING UNIX Previous: What the Prompt is

Ways to Refer to Files (*, ~, .., .)

The asterisk or wildcard * is very useful in referring to files. It matches any string of text. For example, *.tex refers to any files that end in *.tex. All the files in the current directory can be referred to by *. Thus
cp *.tex Papers
will copy all the files with the .tex extension into the directory called Papers.

Watch out! Doing stuff like rm s*.tex is good for removing a list of files called stuff1.tex, stuff2.tex, ... but it will also remove special.tex that you forgot was there. To be safe you can always do ls s*.tex to check what your wildcard is matching before you take action.

One dot . and two dots .. refer to the current directory and the directory one level up, respectively. Thus, cd .. moves you one level up the directory tree. The tilde ~ is used to refer to home directories. For example, cd ~ moves you to your home directory and cd ~smith moves you to the home directory of the user smith.

When you give a command that refers to a file or directory you can always give its full path from your home directory. For directories and files that are contained in your current directory you can just give the name. For example, if you are in a directory called Papers that is contained in your home directory and you want to move to the directory Mail that is also in your home directory, you can do cd ../Mail or cd ~/Mail.