我在使用shell腳本循環時遇到問題。我有一個要求,我必須從平面文件中讀取內容並逐字取代它。例如:嵌套在unix腳本中循環使用
文件內容如下:
Test1 001
Test2 002
和我的腳本如下:
#!/bin/sh
cd /directorypath/bin/
while read line; do
for word in $line; do
for word1 in $line; do
nohup ./startcmd.sh attribute1=$word attribute2=$word1
done
done
done < /directorypath/test1.txt
,但上面的代碼中沒有得到所需的輸出。
我需要的輸出如下:
./startcmd Test1 001
./startcmd Test2 002
任何人都可以請幫我在相同的。
由於
考慮使用的Perl,Python或Ruby像這樣 – JoelFan 2014-10-07 18:55:42
任務,爲什麼你有相同的'在$行字;嵌套? – anubhava 2014-10-07 18:58:08