Linux files and folders copy, move and delete

File copy

cp test.log aaaCopy test.log in the current directory to the aaa folder in
cp test.log ../bbbthe current directory (relative path) Copy test.log in the current directory to the bbb folder in the upper directory (relative path)
cp test.log /usr/aaato the current directory Copy the test.log to the aaa folder under usr (absolute path)

Folder copy

cp dd aaaCopy the dd folder in the current directory to the aaa folder in
cp dd ../bbbthe current directory (relative path) Copy the dd folder in the current directory to the bbb folder in the upper directory (relative path)
cp dd /usr/aaato the current directory Copy the dd folder to the aaa folder under usr (absolute path)

File copy and rename

cp test.log aaa/a.txtCopy test.log in the current directory to the aaa folder in the current directory and rename it to a.txt (relative path)
cp test.log ../bbb/a.txtCopy test.log in the current directory to the bbb folder in the upper level directory and rename it to a .txt (relative path)
cp test.log /usr/ccc/a.txtcopy test.log in the current directory to the ccc folder under usr in the root directory and rename it to a.txt (absolute path)

Folder copy and rename

cp dd aaa/ffCopy the dd folder in the current directory to the aaa folder in the current directory and rename it to ff (relative path)
cp dd ../bbb/ffCopy the dd folder in the current directory to the bbb folder in the upper level directory and rename it to ff (relative path) Path)
cp dd /usr/ccc/ffCopy the dd folder in the current directory to the ccc folder under usr in the root directory and rename it to ff (absolute path)

File move

mv test.log aaMove test.log in the current directory to the aa folder in
mv test.log ../bbthe current directory (relative path) Move test.log in the current directory to the bb folder in the upper directory (relative path)
mv test.log /usr/aato the current directory Move the test.log to the absolute path /usr/aa (absolute path)

Folder move

mv cc aaMove the cc folder in the current directory to the aa folder in
mv cc ../bbthe current directory (relative path) Move the cc folder in the current directory to the bb folder in the upper directory (relative path)
mv cc /usr/aato the current directory Move the cc folder to the absolute path /usr/aa (absolute path)

File move and rename

mv test.log aa/test1.logMove test.log in the current directory to the aa folder in the current directory and rename it to test1.log (relative path)
mv test.log ../bb/test1.logMove test.log in the current directory to the bb folder in the upper directory and rename it is test1.log (relative path)
mv test.log /usr/aa/test1.logto move and rename test.log the absolute path of the current directory / usr / aa is below test1.log (absolute path)

Folder move and rename

mv cc aa/ddMove the cc folder in the current directory to the aa folder in the current directory and rename it to dd (relative path)
mv cc ../bb/ddMove the cc folder in the current directory to the bb folder in the upper directory and rename it to dd (Relative path)
mv cc /usr/aa/ddMove the cc folder in the current directory to the absolute path /usr/aa and rename it to dd (absolute path)

File deletion

rm test.logTo delete a file, there will be a question "rm: remove regular file'test.log'?", type y and press enter to delete n press enter and do not delete
rm -f test.log.

Folder deletion

rm -r aaDelete the files in the directory and below one by one. You will be asked if you want to delete the folder, enter y and press Enter to delete n and press Enter to not delete (rm aa this way of deleting will report an error "cannot remove aa: is a directory") to
rm -rf aaforce the directory and the following files to be deleted one by one (don’t ask)

Guess you like

Origin blog.csdn.net/nongminkouhao/article/details/108009961