Red Hat ENTERPRISE LINUX 4 - STEP BY STEP GUIDE Manual page 68

Table of Contents

Advertisement

54
To copy a file to a different direcoty, specify a path as the third word on the command line:
cp original_file /dir1/dir2/
This command creates a copy of
instead of a directory, the copy has that new name.
cp original_file /dir1/dir2/new_file
This creates a new file named
Alternatively, if you know where the file is and would like to place a copy of it in your current
directory, enter the path as word two and "." as the third word.
cp /dir1/dir2/filename .
The above command places a copy of
4.5.3. Moving files with mv
To move a file or directory from one location to another, use the command
Common useful options for
(interactive) — Prompts you if the file you have selected overwrites an existing file in the
-i
destination directory.
(force) — Overrides the interactive mode and moves without prompting. Be very careful about
-f
using this option.
(verbose) — Shows the progress of the files as they are being moved.
-v
To move a file from the current directory to another location, enter a path as the third word on the
command line.
mv filename /dir1/
This command would remove
Alternatively, a path to the location of the file may be entered as the second word and "." as the thrid
word. This moves the file from the location specified in word two into your current working directory.
mv /tmp/filename .
The above command moves the file
directory.
Finally, both words two and three may be paths.
mv ../../filename /tmp/new_name
The command above moves the file
while renaming the file
original_file
with the contents of
new_file
filename
include:
mv
from the current working directory and place it in
filename
filename
filename
.
new_name
Chapter 4. Shell Prompt Basics
in
. If the last part of the path is a filename
dir2/
original_file
in your current working directory.
from the
directory into your current working
/tmp/
from a directory two levels up to the
in
.
dir2/
.
mv
/dir1/
directory
/tmp/
.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ENTERPRISE LINUX 4 - STEP BY STEP GUIDE and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Enterprise linux 4

Table of Contents