我有以下名稱格式的文件。在bash/shell/unix中刪除給定範圍的文件
test_1_452161_987654321.ARC
test_1_452162_987654321.ARC
test_1_452163_987654321.ARC
.
.
.
test_1_452190_987654321.ARC
即我需要在上述情況下用戶會給出下面輸入
Start_File = 452161
End_File = 452190
如何刪除上述一系列文件刪除30個文件? (我是新來砸向/ shell編程我試着用while循環,並刪除其力的工作,以便尋求專家幫助)
我的代碼
echo "Enter Start File"
read start
echo "Enter End File"
read end
i=$start
j=$end
while [$i -le $j]; do
rm *$i*.ARC
((i++))
done
如果在while測試中''''之前''''之前添加空格,那麼您的腳本將起作用。如果文件名稱範圍有空白,您可能需要使用'rm -f'來避免錯誤消息。 – mhawke