This article describes the underlying file operations: Create, move, edit, delete files and folders
Command and Case:
mkdir Creating a Directory
--Create two directories
[Email protected]:~$ mkdir test2 test3
--Create a new directory under Test1 Mydir
[Email protected]:~$ mkdir Test1/mydir
--Try to create a new directory under test100 Mydir, but not successful because test100 this directory does not exist
[Email protected]:~$ mkdir test100/mydir mkdir:cannot Create directory ' Test100/mydir ': No such file or directory
--Force the creation of two files for father and son, although test100 this parent directory does not exist
[Email protected]:~$ mkdir-p Test100/mydir
Touch Create File
--Create a hello file in the current directory
[Email protected]:~$ Touch Hello Echo
--write "Hello" to this directory
[Email protected]:~/test1$ cat Hellobackup[email protected]:~/test1$ echo "Hello" > hellobackup [email protected]:~/ test1$ Cat Hellobackuphello
MV Move or rename files
--Move the file hello to the Test1 folder
[Email protected]:~$ mv Hello Test1
--Rename file Hello to Hellobackup
[Email protected]:~/test1$ mv Hello Hellobackup
CP Copy File
[Email protected]:~$ cp pse2 test2--Copy file Pse2 to Test2 folder
Rm/rmdir deleting files and folders
--Delete File Hello
[Email protected]:~$ rm Hello
--Delete Folder Test2
[Email protected]:~$ rmdir test2
Input Redirect to file:
The following will write the input of the interface to the file Hellobackup file
[Email protected]:~$ cat <<eof >hellobackup> Hello world!> real func> EOF
Often read the contents of the file [email protected]:~$ cat Hellobackuphello world!real func[email protected]:~$
Complete example (create and delete files)
[Email protected]:~$ cd mhydir[email protected]:~/mhydir$ ls[email protected]:~/mhydir$ Touch test[email protected]:~/ mhydir$ lstest[email protected]:~/mhydir$ rm test[email protected]:~/mhydir$ ls[email protected]:~/mhydir$ Touch test[ Email protected]:~/mhydir$ rm-i Test--will Confirm Whether delete the Filerm:remove regular empty file ' test '? N[email protected]:~/mhydir$ lstest[email protected]:~/mhydir$ rm-i testrm:remove Regular empty file ' test '? Y[email protected]:~/mhydir$ Ls[email protected]:~/mhydir$
Linux Shell: File directory Operations and instances