自己想到的命令
mkdir 【path】新建文件夾
touch [path] 新建文件
echo [content] > [path] 將content內(nèi)容寫(xiě)入到路徑path的文件中,且要擦除原有的數(shù)據(jù)
echo [content] >> [path] 將content內(nèi)容寫(xiě)入到路徑path的文件中,不擦除原有的數(shù)據(jù),content加入到文件的最后面
創(chuàng)建批處理文件
mkdir commandtouch ./command/command.shecho "mkdir aa" >> ./command/command.shecho "mkdir aa1" >> ./command/command.shecho "mkdir aa2" >> ./command/command.shecho "mkdir aa3" >> ./command/command.shchmod +x ./command/command.sh./command/command.shmkdir是在當(dāng)前目錄下建立一個(gè)文件夾command,在command文件夾下創(chuàng)建command.sh 文件,echo將命令內(nèi)容寫(xiě)入到對(duì)應(yīng)的.sh文件中,chmod +x ./command/command.sh讓sh文件變成可執(zhí)行。最終運(yùn)行./command/command.sh文件,就會(huì)運(yùn)行該文件中的各個(gè)命令了。.sh文件中的內(nèi)容每一行代表一條命令。其中echo寫(xiě)入到文件的內(nèi)容是自帶換行的。
chmod命令的作用
首先你要讓文件有能夠執(zhí)行的權(quán)限,比如你的文件是a.sh那么你可以chmod +x a.sh然后運(yùn)行文件就可以了./a.sh這樣運(yùn)行是a.sh在當(dāng)前工作目錄,如果文件沒(méi)在當(dāng)前目錄,那么就需要用絕對(duì)路徑來(lái)執(zhí)行,比如/opt/a.sh/opt/test/a.sh
|
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注