In the OPT directory there is a test1 directory, test1 under the Test2 directory, that is/opt/test1/test2
First, Directory creation
Create a new test2123 folder under the/opt/test1 directory
Mkdir/opt/test1/test2123
Second, directory replication
1. Copy the files and folders inside the/opt/test1/test2 into the opt/test1/test2123 directory
Cp-a/opt/test1/test2/*/opt/test1/test2123
2. Copy the folders and files under the/opt/test1/test2123/abc/to the opt/test1/test2123 directory
Cp-a/opt/test1/test2123/abc/*/opt/test1/test2123
3. Copy the/opt/test1/test2 directory to the/opt/test1/test2123 directory, that is, test2 copy into a test2123 subdirectory, the path to/opt/test1/test2123/test2
Cp-a/opt/test1/test2/opt/test1/test2123
Iii.. Catalog Cut
1. Use the MV command to cut the file.
If you need to cut the 1.mp3 file in the/opt/test1/test2123/music/directory into the/OPT/TEST1/TEST2123/ABC directory, execute the following command:
# MV/OPT/TEST1/TEST2123/MUSIC/1.MP3/OPT/TEST1/TEST2123/ABC
2. Use the MV command to cut the folder.
Cut the/opt/test1/test2123/soft folder into the/OPT/TEST1/TEST2123/ABC directory
# MV/OPT/TEST1/TEST2123/SOFT/OPT/TEST1/TEST2123/ABC
3. Use the MV command to cut folders and files
Cut the folders and files under the/opt/test1/test2123/photo/to the/OPT/TEST1/TEST2123/ABC directory
# mv/opt/test1/test2123/photo/*/OPT/TEST1/TEST2123/ABC
Iv. Directory renaming
Under Linux, moving files and renaming is the same command, MV (meaning of Move)
Command: MV source file name destination file name
1. Rename the/opt/test1/test2123/index.htm to/opt/test1/test2123/index.html
# mv/opt/test1/test2123/index.htm/opt/test1/test2123/index.html
2. Rename the/opt/test1/test2123 directory to/opt/test1/test2456
# mv/opt/test1/test2123/opt/test1/test2456
V. Directory deletion
Linux Delete directory is very simple, many people are still accustomed to use rmdir, but once the directory is not empty, it fell into deep distress, now use the RM-RF command.
Direct RM is available, but add two parameters-rf
That is: RM-RF directory name
-R is recursive down, no matter how many levels of directory, delete
-F is directly forcibly deleted, without any hint of meaning
1. Delete File Usage instances:
Rm-f/opt/test1/test2456/index.html
This file will be forcibly deleted/opt/test1/test2456/index.html
2. Clear the folder instance:
rm-rf/opt/test1/test2456/abc/*
All files, folders, and/OPT/TEST1/TEST2456/ABC directories in the/OPT/TEST1/TEST2456/ABC directory will be forcibly deleted.
3. Delete the folder instance:
rm-rf/opt/test1/test2456
Will force the deletion of the/opt/test1/test2456 directory and all files and folders under it
To be reminded: Use this RM-RF with extreme caution, Linux does not have a recycle Bin
Of course, RM has more parameters and usage, and man RM can view the
If you are operating under the/opt/test1/directory, you can omit the/opt/test1/part of each command
4. Compression (Zip) and decompression (unzip) command:
I need to back up the/opt/test1 folder, but because of the number of files in the Test1 tens of thousands of or more, this time need to use the zip command, first compressed the test1 file after transmission:
Cd/test1 Locate the path on the Test1 folder
Zip-r Test1.zip Wwwrot So the Lord has packed all the files and folders under Test1.
The same reason, the compressed file into the CentOS inside, you can use unzip decompression files, GCA, will/opt/test1.zip decompression, you can use the following command:
Cd/opt
Unzip Test1.zip
1. I want to compress a file abc.txt and a directory dir1 into Yasuo.zip:
# zip-r Yasuo.zip abc.txt Dir1
2. I downloaded a yasuo.zip file and want to unzip it:
# Unzip Yasuo.zip
3. I have Abc1.zip,abc2.zip and Abc3.zip in the current directory, and I want to unzip them together:
# unzip abc\? Zip
Note: A character is represented if any number of characters are represented by *.
4. I have a very large compressed file large.zip, I do not want to decompress, just want to see what is inside it:
# unzip-v Large.zip
5. I downloaded a compressed file large.zip, want to verify that the compressed file is completely downloaded
# unzip-t Large.zip
6. I use the-v option to find that Music.zip compressed files have many directories and subdirectories, and the subdirectories are actually songs mp3 files, I would like to download these files to the first level directory, rather than a layer of building a directory:
# unzip-j Music.zip
Refer to the original link : https://www.cnblogs.com/zengjs/p/3169473.html
Blog is to remember that they are easy to forget things, but also a summary of their work, the article can be reproduced, without copyright. Hope to do their own efforts to do better, we work together to improve!
If there is any problem, welcome to discuss together, code if there is a problem, you are welcome to the great God!
Create, copy, cut, rename, empty, and delete commands for folders under Linux