 |
|
Moving and renaming files
Oracle Tips by Burleson Consulting
|
There will come a time when you will need to move a file or maybe a group of
similarly named files to a different directory; or maybe you would just like
to rename a file to a new name. The mv (move) command is used to perform
both move and rename functions.
The rules for mv are similar to those
for rm described earlier, in that file references can be via a fully
qualified path or via a relative path. The use of the wildcard symbols in
the filename is also allowed. Let’s take a look at some examples.
Move file example1.fil from the current working directory to the /tmp
directory:
mv
touch1.fil /tmpMove file example1.fil using the fully
qualified path to the /tmp directory:
mv /home/tclark/touch1.fil /tmp
Create and rename example1.fil in the /tmp directory to example1.xxx (we are
in our home directory):
Directory:~
$ cd /tmp
Directory:/tmp
$
touch temp1.fil temp2.fil create files in /tmp
Directory:/tmp
$ ls
-l temp*
-rw-rw-r-- 1 tclark tclark 0 Jan 13 21:15
temp1.fil
-rw-rw-r--
1 tclark tclark 0 Jan 13 21:15
temp2.fil
Directory:/tmp
$ cd -
change to my home
directory
/home/tclark
Directory:~
$ mv /tmp/temp1.fil
/tmp/temp1.xxx rename a file
in the /tmp directory
Directory:~
$ cd - switch back to /tmp
/tmp
Directory:/tmp
$ ls temp*
verify the file was
renamed
temp1.xxx temp2.fil
Directory:/tmp
$Rename example2.fil in the current working directory
to example2.xxx:
Directory:~
$ ls
examples
Directory:~
$ touch example1.fil
example2.fil create 2 files
in my home directory
Directory:~
$
ls
example1.fil example2.fil examples
Directory:~
$ mv
example2.fil example2.xxx rename 1 of the files
Directory:~
$ ls
verify the file
was renamed
example1.fil example2.xxx examples
The above book excerpt is from:
Easy Linux
Commands
Working Examples of Linux Command Syntax
ISBN:
0-9759135-0-6
Terry Clark