How to Copying/Renaming/Deleting a directory in unix?

How to Copying/Renaming/Deleting a directory in unix?

Senior Developer Asked on December 7, 2017 in UNIX.
Add Comment
1 Answer(s)

Copying a Directory:
You can use the cp command to create a duplicate copy of a directory and its contents. To copy directory dir1 to directory dir2, type the below command.


cp -r dir1 dir2

Renaming Directory:
You can also use the mv command to rename and move directories. Just type the below command.The directory called dir1 will be given the new name dir2.


mv dir1 dir2

Deleting Directory:
To remove directories with rm, you must specify the -r option {recursive} It will remove all of the files and the subdirectories of the specified directory.


rm -r abc // abc is directory name

Team Leader Answered on December 31, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.