Macbook Pro 사용기/OSX Command
rm 파일 및 하위 디렉토리 삭제
向雲™
2011. 10. 15. 18:45
NAME
rm, unlink -- 디렉토리 엔트리를 삭제
SYNOPSIS
rm [-dfiPRrvW] file ...
unlink file
DESCRIPTION
The rm utility attempts to remove the non-directory type files specified
on the command line. If the permissions of the file do not permit writ-
ing, and the standard input device is a terminal, the user is prompted
(on the standard error output) for confirmation.
The options are as follows:
-d | 다른 유형의 파일뿐만 아니라 디렉토리들을 지움(디렉토리 내에 파일이 존재하거나 하위 디렉토리가 존재하는 경우에는 삭제되지 않음 |
-f | Permission에 상황관없이 확인 메시지 없이 파일을 삭제한다. 파일이 해당 디렉토리에 존재하지 않을 경우에 어떠한 에러 메시지도 출력하지 않는다. -f 옵션앞에 -i 옵션이 있을 경우에 -i 옵션은 무시된다. |
-i | Permission에 상관없이 각 파일을 삭제하기 전에 확인을 요구한다. 또한 표준 입력 디바이스가 터미널이든 아니든 상관하지 않는다. -i 옵션 앞에 -f 옵션이 있을 경우에 -i 옵션은 무시된다. |
-P Overwrite regular files before deleting them. Files are
overwritten three times, first with the byte pattern 0xff,
then 0x00, and then 0xff again, before they are deleted.
-R 해당 디렉토리와 하위의 파일 및 디렉토리를 삭제한다. -R 옵션은 -d 옵션을 포함하고 있어서 별도로 -d 옵션을 지정하지 않아도 된다. 만약 -i 옵션을 사용하게 되면 각 디렉토리들이 지원지기 전에 사용자 확인 메시지가 나타난다. 사용자가 알맞은 응답을 하지 않았을 경우에 해당 디렉토리와 하위 디렉토리의 삭제는 취소된다.
-r -R 옵션과 동일
-v Be verbose when deleting files, showing them as they are
removed.
-W Attempt to undelete the named files. Currently, this option
can only be used to recover files covered by whiteouts.
The rm utility removes symbolic links, not the files referenced by the
links.
It is an error to attempt to remove the files ``.'' or ``..''.
When the utility is called as unlink, only one argument, which must not
be a directory, may be supplied. No options may be supplied in this sim-
ple mode of operation, which performs an unlink(2) operation on the
passed argument.
The rm utility exits 0 if all of the named files or file hierarchies were
removed, or if the -f option was specified and all of the existing files
or file hierarchies were removed. If an error occurs, rm exits with a
value >0.
NOTE
The rm command uses getopt(3) to parse its arguments, which allows it to
accept the `--' option which will cause it to stop processing flag
options at that point. This will allow the removal of file names that
begin with a dash (`-'). For example:
rm -- -filename
The same behavior can be obtained by using an absolute or relative path
reference. For example:
rm /home/user/-filename
rm ./-filename
SEE ALSO
rmdir(1), undelete(2), unlink(2), fts(3), getopt(3), symlink(7)
BUGS
The -P option assumes that the underlying file system is a fixed-block
file system. In addition, only regular files are overwritten, other
types of files are not.
COMPATIBILITY
The rm utility differs from historical implementations in that the -f
option only masks attempts to remove non-existent files instead of mask-
ing a large variety of errors. The -v option is non-standard and its use
in scripts is not recommended.
Also, historical BSD implementations prompted on the standard output, not
the standard error output.
STANDARDS
The rm command is almost IEEE Std 1003.2 (``POSIX.2'') compatible, except
that POSIX requires rm to act like rmdir(1) when the file specified is a
directory. This implementation requires the -d option if such behavior
is desired. This follows the historical behavior of rm with respect to
directories.
The simplified unlink command conforms to Version 2 of the Single UNIX
Specification (``SUSv2'').
HISTORY
A rm command appeared in Version 1 AT&T UNIX.
-d | 다른 유형의 파일뿐만 아니라 디렉토리들을 지움(디렉토리 내에 파일이 존재하거나 하위 디렉토리가 존재하는 경우에는 삭제되지 않음. |