Wednesday, September 3, 2014

[Quick Tips] : How to rename and move the directory and files in linux

How to rename and move the directory and files in linux

To rename and move the directory and files in linux in linux we use single command called mv.
The mv command is used for both purpose means renaming and moving the directory or file,it is system command which ships bydefault when you install any linux. The command is also applicable to all Unix based operating system.
Syntax: mv [options] SOURCE DESTINATION

Move and rename directory or file in linux

Note: mv command is applicable to both directory and files.
Here for we have created a directory called test and the example is same with file also
Now we will rename the directory.
Syntax: mv dir-name new-dir-name
Reference:
linux@tuxworld:/tmp$ mv test/ newtest
linux@tuxworld:/tmp$ ls -ld *test*
drwxrwxr-x 2 linux linux 4096 Aug 18 01:41 newtest
linux@tuxworld:/tmp$
Now we will move the directory
Syntax: mv dir-name /destination/path
Lets see,one more example of renaming the directory
Syntax: mv dir-name /path/you/want/to/move/new-dir-name

How to move multiple directories or file

Note: The below given example is applicable to directory
Syntax example: mv directory1 directory2 directoryn -t /path/of/Destination-Directory
Use -t option

How to move multiple files into destination directory or path

Syntax example: mv filename1 filename2 filenamen -t /path/of/Destination-Directory

No comments: