Subdirectories
It is a good idea to create your own subdirectories in which to
organize your files. This will make managing your files much easier.
Let's say you want to make a directory 'src' in which to put all the
files containing sources of programs you have written. You type
to create the subdirectory, and move the files into it by typing
which will move all the files with a '.c' extension to the
'src' area. Now if you type "ls -l" you should see something like
this:
total 3
-rw-r--r-- 1 jsmith 56732 Apr 1 14:51 junk
-rw-r--r-- 1 jsmith 1684 Apr 2 14:50 temp
drwxr-xr-x 2 jsmith 24 Apr 2 14:50 src
If you wish to move to your source directory, you can use the "cd"
(change directory) command:
Now your current directory is
/users/admin/jsmith/src.
Any files you create will be in this directory.
You can move to the directory immediately above you by typing:
If you use the "cd" command without any argument, you will be put back
into your home directory. Another time saver
in naming files is the use of the tilde (~). You can use this to prefix
a user's home directory instead of typing out his full pathname. For
example, to get a listing of the files under Fred Rated's directory,
you can type "ls ~frated" rather than "ls /users/admin/frated".
A tilde without a username refers to your own home directory, so you
can type "ls ~" to get a list of the files in your own home directory
no matter what directory you may be in.
To remove the directory 'src' (assuming that your current working
directory is:)
/users/admin/jsmith
type:
The first command removes all files from the directory; the second
removes the now-empty directory. (You can't delete a directory unless
it's empty.)
Click here to go to the next section.
Or click here to go to the top
of the chapter.