Information Technology Reference
In-Depth Information
argument is specified, all parent directories that are empty will also be
removed. The -s command-line argument is used to suppress error mes-
sages. This code shows a recursive long listing:
# ls -lR /test
/test:
total 2
drwxr-xr-x 3 root other 512 Apr 13 17:33 Solaris
/test/Solaris:
total 2
drwxr-xr-x 2 root other 512 Apr 13 17:33 9
/test/Solaris/9:
total 0
# rmdir /test/Solaris/9
# ls -lR /test
/test:
total 2
drwxr-xr-x 2 root other 512 Apr 13 19:15 Solaris
/test/Solaris:
total 0
# rmdir -p /test/Solaris
# ls -lr /test
/test: No such file or directory
#
The rm(1) command can also be used to remove one or more directories
specified as command-line arguments (separated by spaces). Directories can
only be removed if the -R or -r command-line argument is specified. Either
of these command-line arguments will recursively remove all files and direc-
tories under the directory being removed, as well as the directory itself. Note
that the rmdir command can be used to remove parent directories (directo-
ries above the directory being removed):
# mkdir -p /test/Solaris/9
# rm /test
rm: /test is a directory
# rm -r /test
# ls -lr /test
/test: No such file or directory
#
The -i command-line argument provides interactive control over the
remove command, as shown in the following:
# mkdir -p /test/Solaris/9
# rm -r -i /test
rm: examine files in directory /test (yes/no)? y
Search WWH ::




Custom Search