Filenames

The Unix filesystem looks like an upside down tree. There is one directory at the top called '/' (slash) or the "root" directory. All the other files in the filesystem are "below" this directory in many layers of subdirectories. If I type "pwd" (Print Working Directory) I will find out the name of my current directory: % pwd /users/physics/jsmith % This shows that my current directory is called 'jsmith' and it is "under" the directories '/users' and '/physics'. I can list the files in my current directory by typing "ls" and I can see what files are in a different directory by typing "ls" followed by a path. For example, what files are kept in '/usr/local'? % ls /usr/local IDEpipesh* fanno@ nbbc* rmf* Pnews* fc* netcon* rmm* Rnmail* finger* newsetup* rmt* ali* folder* newsgroups* rn* anno* folders* next* rprompt* ansitar* forw* nmsh* rrn@ apropos@ fstype* nn* rtar* . . % [The directory name '/usr/local' is an "absolute" or "rooted" pathname because it starts with '/' (the root directory).]

There are certain shorthand ways of referring to files or groups of files without typing the full filename(s). The special characters that allow this are sometimes called "wildcard" characters. The most popular one is "*" which will match any or all characters. For example, "ls f*" will list all files in the current directory that begin with f, or "ls a*b" will list all files that begin with a and end with b.

*
matches any characters
?
matches any one character
[abc]
matches characters a or b or c

Click here to go to the next section.

Or click here to go to the top of the chapter.