微信商城與網(wǎng)站一體/谷歌瀏覽器下載手機版中文
一、查看文件內(nèi)容命令
1、cat 文件名:用于顯示文件內(nèi)容,比如 cat test.c。
(1)cat -b test.c 表示加行號顯示文件內(nèi)容。
(2)cat -s test.c 表示多個空行合并成一個空行顯示。
2、nl 文件名:用于加行號顯示文件內(nèi)容,例如 nl test.c。
3、head [-n] 文件名:表示顯示前n行內(nèi)容,默認(rèn)是前10行。
4、tail [-n] 文件名:表示顯示后n行內(nèi)容,默認(rèn)是后10行。
二、復(fù)制命令
1、cp [option] file destination:用于將文件file復(fù)制到destination。
(1)復(fù)制到文件夾下,文件名不變。
cp test.c Test 將test.c文件復(fù)制到Test文件夾中
(2)復(fù)制到文件中,文件名改變。
cp test.c test2.c 將test.c復(fù)制到test2.c中
(3)復(fù)制多個文件到文件夾中。
cp 源文件1 源文件2 … 文件夾
cp first first.c Test
(4)復(fù)制以*開頭的文件到文件夾中。
可以使用通配符*代替文件名。
2、其中option包括:
(1)i 覆蓋時交互提示。
(2)r對文件夾遞歸。
(3)復(fù)制多個文件到文件夾
(4)cp [option] file1 file2 dest
例如:cp test.c test1.c 表示 將test.c中的內(nèi)容復(fù)制到test1.c當(dāng)中。
cp test.c /home/linux 表示將test.c復(fù)制到/home/linux目錄中。
cp -r testsubdir/ bakdir 表示將testsubdir復(fù)制到bakdir中。(文件夾復(fù)制)
cp -i test.c …/ 表示在覆蓋時進行提示。(假設(shè)上級目錄中有test.c文件)
三、移動命令
1、mv [option] file destination:用于將文件file移動到destination。
(1)移動多個文件:mv [option] file1 file2 destination :表示將文件1 2 移動到destination中。例如:mv test.c …/ 表示將test.c移動到上一級目錄中。
(2)重命名:mv file1 file2,表示重命名。例如:mv test2.c test_second.c 表示將test2.c 重命名為 test_second.c。
注意:使用此命令時,源文件和目標(biāo)文件必須在同一個路徑下。
(3)移動+重命名:mv file1 路徑 file2,表示將文件file1移動到路徑中并重命名為file2。例如:mv test3.c …/test_three.c。
(4)移動包括*的文件:mv *文件 目標(biāo)文件夾
例如:mv exam Test 將exam開頭的文件移動到Test文件夾中。*
四、創(chuàng)建和刪除文件
1、touch:表示創(chuàng)建文件或更新時間戳(修改時間)。例如:touch a.c 表示創(chuàng)建一個a.c文件。
2、rm [opion] option包含-i :表示刪除文件;-r:表示刪除文件夾。
例如:rm test1.txt
rm test1.txt test2.txt 刪除多個文件
-f:強制模式不提示確認(rèn)直接刪除
-i:刪除前詢問是否確認(rèn)刪除
五、創(chuàng)建和刪除目錄
1、mkdir 文件夾名 表示創(chuàng)建文件夾。例如:mkdir dd。其中-p表示級聯(lián)創(chuàng)建。例如:mkdir -p d2/d22 表示在d2文件夾下創(chuàng)建d22文件夾。
2、rm 文件夾名 表示刪除文件夾。例如rm dd。其中-r表示遞歸刪除目錄及內(nèi)容,也就是也將子目錄刪除。
3、rmdir命令: rmdir [選項] 目錄名:刪除空目錄。
注:如果目錄不為空,則直接用-p 遞歸刪除目錄。
刪除后,Demo文件夾消失。