[英]Is it possible to find files by the exact date then execute tar command on the results files?
[英]Find files and execute command
我有很多rar檔案在單個文件夾中構建,並希望腳本解壓縮它們。
我無法弄清楚它應該如何完成並需要一些幫助。
#!/bin/bash
## For all inodes
for i in pwd; do
## If it's a directory
if [ -d "$i" ] then
cd $i
## Find ".rar" file
for [f in *.rar]; do
./bin/unrar x "$f" # Run unrar command on filename
cd ..
done
done
done
我不熟悉bash腳本,我認為代碼錯誤不止一次。 但我想這應該是基本結構
您不需要腳本。
find . -name "*.rar" -exec unrar x {} \;
此外,您可以將find的結果傳遞給unrar
命令。
find . -name "*.rar" | xargs unrar x
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.