Red Hat LINUX 7.2 Manual page 135

Hide thumbs Also See for LINUX 7.2:
Table of Contents

Advertisement

Section 11.8:Manipulating Files at a Shell Prompt
11.8.4 Deleting Files and Directories
You learned about creating files with the touch command and by using redirection in Chapter 10,
Shell Prompt Basics . And you created the directory tigger using mkdir.
Now you need to learn how to delete files and directories. Deleting files and directories with the
rm command is a straightforward process. See the rm man page for more information. Options for
removing files and directories include:
-i — interactive. Prompts you to confirm the deletion. This option can stop you from deleting a
file by mistake.
-f — force. Overrides interactive mode and removes the file(s) without prompting. This might
not be a good idea, unless you know exactly what you are doing.
-v — verbose. Shows a list of files as they are being removed.
-r — recursive. Will delete a directory and all (if any) files and the subdirectories it contains.
To delete the file piglet.txt from the tigger directory with the rm command:
rm piglet.txt
What happens if you did not really want to get rid of it? Too late! That is where the -i (interactive)
option is helpful, because it gives you a second chance to think about whether or not you really want
to delete the file.
[newuser@localhost newuser]$
rm -i piglet.txt
rm: remove 'piglet.txt'?
You can also delete files using the wildcard *, but be careful, because you can easily delete files you
did not intend to throw away.
To remove a file using a wildcard, you would type:
rm pig*
The above command will remove all files in the directory which start with the letters "pig."
You can also remove more than one file using one command:
rm piglet.txt sneakers.txt
Options for removing files and directories include the following:
-i — interactive. Prompts you to confirm the deletion. This option can stop you from deleting
a file by mistake. .
135

Advertisement

Table of Contents
loading

This manual is also suitable for:

Linux 7.2

Table of Contents