
17.5 Copying, Moving and Renaming Files and Directories 267
-f – force. Copies without prompting you for confirmation that the file should be overwritten.
Unless you’re sure you want to force the copy, you probably don’t want to make friends with
this option right now.
-v - verbose. Will show the progress of the files being copied.
Just by using cp alone, you won’t see much when the command is executed. Using an option, such
as -i, can make the process a little more useful, because if you want to copy a file to a location that
already has a file with the same name, you’ll be asked first if you really want to overwrite – meaning
replace – the file that’s already there.
Tip: Remember that among your options is -f (force), which can overwrite files with-
out asking you if you’re certain. Make sure, when you use the force option, that you
really want to overwrite a file.
Now that we have the file sneakers.txt in the tigger directory, let’susecp -i to copy the file
again to the same location.
[billy@localhost billy]$ cp -i sneakers.txt tigger
cp: overwrite ’tigger/sneakers.txt’?
If we want to overwrite the file that’s already there, we can press
Y and then Enter . If we think we
don’t want to overwrite the file, now’s the time to press
N and Enter .
17.5.2 Moving Files
To move files, use the mv command (man mv), which is similar to the cp command, except that with
mv the file is physically moved from one place to another, instead of being duplicated, as with cp.
Common options available with mv include:
-i – interactive. Will prompt you if the file you’ve selected will overwrite an existing file in the
destination directory. This is a good option, because like the -i option in cp,you’ll be given
the chance to make sure you want to replace an existing file.
-f – force. Overrides the interactive mode and moves without prompting. Unless you know
what you’re doing, this option doesn’t play nice; be very careful about using it until you be-
come more comfortable with your system.
-v – verbose. Shows a list of the files being moved.
Comentarios a estos manuales