Working with Directories

 < Day Day Up > 

This section covers deleting directories, copying and moving files between directories, and moving directories. It also describes how to use pathnames to make your work with Linux easier.

rmdir: Deletes a directory

The rmdir (remove directory) utility deletes a directory. You cannot delete the working directory or a directory that contains files other than . and . . entries. If you need to delete a directory with files in it, first use rm to delete the files and then delete the directory. You do not have to (nor can you) delete the . and . . entries; rmdir removes them automatically. The following command deletes the directory that was created in Figure 4-5 on page 81:

 $ rmdir /home/alex/literature 

The rm utility has a r option (rm r filename) that recursively deletes files, including directories, within a directory as well as the directory itself.

caution: Use rm r carefully, if at all

Although rm r is a handy command, you must use it carefully. Do not use it with an ambiguous file reference such as *. It is quite easy to wipe out your entire home directory with a single short command.


Pathnames

     < Day Day Up > 


    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net