-1
字符串我有一個文件file.dat
如下:選擇文件CSH
1.1,2.1 1.4
3.1,2.1 2.4
2.4,4.5 11.5
..
我希望每次整行(串)選擇並在另一個文件將其替換。到目前爲止,我嘗試了以下
#!/bin/csh
set FILENAME = 'file.dat' # file in which the strings are
set str = "229.8,230.9 230.36" # initialize the first string
set n = 1
while ($n <= 3) # number of lines in the FILENAME
echo Testing the first string $str
set rep = $(head -n $n "$FILENAME")
@ n++ # increment the index
end
當我嘗試啓動我得到下列錯誤消息
Testing the first string 229.8,230.9 230.36
Illegal variable name. # connect with the rep definition(?)
腳本
csh launch.sh
中,我要改變字符串str
的文件是如下(本是順便說一句,我可以通過自己一次,我明白在第一線的錯想出一個次要問題):
# Name Type Par
Mi FI 154.2355189465
So UN 229.8,230.9 230.36 # line to be changed
Za FI 0.8000020209
五月有人幫助我,對租?
爲什麼你的標題和標籤說'bash'當你的代碼實際上使用'csh'? – melpomene
@melpomene因爲如果沒有找到使用'csh'的解決方案,我會無論如何滿意'bash'的解決方案。 –