我想解壓縮特定目錄中的所有檔案,但不知道如何使用 shell 腳本來解壓。
Lgl_Entitiy.txt.zip
Lgl_Entitiy.txt_1.zip
Lgl_Relate.txt.zip
Lgl_Relate.txt_1.zip
Lgl_Name.txt.zip
Lgl_Name.txt_1.zip
uj5u.com熱心網友回復:
安裝解壓:
sudo apt install 解壓或 yum install unzip
在要解壓縮檔案的同一目錄中使用它:
unzip ‘*.zip’
如果要將未壓縮的檔案放在其他目錄中,請使用以下命令:
unzip ‘*.zip’ -d /usr/sampleZip/ExampleDir
把它放到一個shell腳本中:
vim shellscript.sh
那么腳本可能是這樣的:
#!/bin/bash
unzip ‘*.zip’
保存腳本后,執行它:
./shellscript.sh
uj5u.com熱心網友回復:
您可以使用簡單的解壓縮命令。
讓我給你舉個例子:
- 進入您擁有 zip 檔案的目錄。
cd /home/rexter/test
- 這個位置有幾個 zip 檔案。
ls
1.zip
2.zip
3.zip
- 現在,如果您想將它們全部解壓縮,只需鍵入:
unzip '*.zip'
大功告成!
########################
正如你想要的腳本一樣。這里只是相應地編輯
#!/bin/bash
cd <path-to-your-directory>
unzip '*.zip'
將此檔案另存為 unzipscript.sh 并使用“sudo chmod x unzipscript.sh”為其授予可執行權限,然后運行此腳本。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/368552.html
上一篇:意外標記“完成”附近的語法錯誤?
