String 从csh文件中选择一个字符串
我有一个文件String 从csh文件中选择一个字符串,string,csh,String,Csh,我有一个文件file.dat,如下所示: 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 whi
file.dat
,如下所示:
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
我想更改字符串str
的文件如下所示(顺便说一句,这是第二个问题,一旦我理解了第一行中的错误,我可以自己解决):
谁能帮帮我吗?$(…)
是Bash中用于命令替换的Bash语法
当你的代码实际使用
csh
时,为什么你的标题和标签会说bash
?@melpomene因为如果找不到使用csh
的解决方案,我无论如何都会对涉及bash
的解决方案感到满意。
Testing the first string 229.8,230.9 230.36
Illegal variable name. # connect with the rep definition(?)
# Name Type Par
Mi FI 154.2355189465
So UN 229.8,230.9 230.36 # line to be changed
Za FI 0.8000020209