Red Hat ENTERPRISE LINUX 3 - STEP BY STEP GUIDE Manual page 70

Table of Contents

Advertisement

56
Replace
filename
the new file contains zero (0) bytes of information because it is an empty file. For example, typing the
command
ls -l newfile
-rw-rw-r--
1 sam
4.4.2. Copying Files
Like so many other Linux features, there is a variety of ways to manipulate files and directories. You
can also use wildcards, as explained in Section 3.10.5 Wildcards and Regular Expressions, to make
the process of copying, moving, or deleting multiple files and directories faster.
To copy a file, type the following command.
cp
source
destination
"
# $ "
Replace
source
!
name of the directory where you want the file to go.
To copy the file
sneakers.txt
directory and type:
cp sneakers.txt tigger/
You can use both relative and absolute pathnames with
directory
;
tigger/
tigger/
Tip
To learn more about relative and absolute pathnames, refer to Section 3.4 Changing Directories with
.
cd
Read the
man page (type
cp
. Among the options you can use with
cp
(interactive) — Prompts you to confirm if the file is going to overwrite a file in your destination.
-i
This is a handy option because it can help prevent you from making mistakes.
(recursive) — Rather than just copying all the specified files and directories, this copies the
-r
whole directory tree, subdirectories and all.
(verbose) — Shows the progress of the files as they are being copied.
-v
Now that you have the file
to the same location.
cp -i sneakers.txt tigger/
cp: overwrite 'tigger/sneakers.txt'?
To overwrite the file that is already there, press [Y] and then [Enter]. If you do not want to overwrite
the file, press [N] and [Enter].
with the name of your choice. If you run a directory listing, you can see that
!
at the shell prompt returns the following output:
sam
#
with the name of the file you want to copy, and
to the directory
is one directory down from our home directory.
at the shell prompt) for a full list of the options available with
man cp
cp
in the
sneakers.txt
Chapter 4. Managing Files and Directories
0 Apr 10 17:09 newfile
in your home directory, move to your home
tigger/
. Our home directory is the parent of the
cp
are the following:
directory, use
tigger/
with the
destination
!
to copy the file again
cp -i

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents