我需要創建Bash腳本,通過file050.txt生成名爲file001.txt的文本文件 在這些文件中,所有文本都應該插入「This if xxx文件編號」(其中xxx是分配的文件編號),除了file007.txt,需要我爲空。如何創建一個Bash腳本來創建包含文本的多個文件?
這是我迄今爲止..
#!/bin/bash
touch {001..050}.txt
for f in {001..050}
do
echo This is file number > "$f.txt"
done
不知道在哪裏可以從這裏走。任何幫助將非常感激。
您是否嘗試過使用循環內的'if'聲明,或通過如下覆蓋你所選擇的文件(file007.txt)如'回聲> file007.txt'的循環? –
'touch'有什麼意義?它只是重定向到文件中而沒有做什麼? –