-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'的解决方案。 –