如何根据换行符而不是 csh 中的 space 迭代变量中的每一行
how to iterate every line from variable on the basis of new line character instead of space in csh
#!/bin/csh -f
foreach line (`cat test.txt`)
echo "$line"
end
test.txt 文件包含以下内容:
How to Ask
Is your question about programming?
We prefer questions that can be answered, not just discussed.
Provide details. Share your research.
If your question is about this website, ask it on meta instead.
但是在 运行 上面 csh script 我得到以下输出,它基于 space 分隔符而不是新行
./test.csh
输出在文件中
你可以用这个;
#!/bin/csh -f
foreach line ( "`cat test.txt`" )
echo $line
end
测试:
$ csh test.csh
How to Ask
Is your question about programming
We prefer questions that can be answered, not just discussed.
Provide details. Share your research.
If your question is about this website, ask it on meta instead.
#!/bin/csh -f
foreach line (`cat test.txt`)
echo "$line"
end
test.txt 文件包含以下内容:
How to Ask
Is your question about programming?
We prefer questions that can be answered, not just discussed.
Provide details. Share your research.
If your question is about this website, ask it on meta instead.
但是在 运行 上面 csh script 我得到以下输出,它基于 space 分隔符而不是新行
./test.csh
输出在文件中
你可以用这个;
#!/bin/csh -f
foreach line ( "`cat test.txt`" )
echo $line
end
测试:
$ csh test.csh
How to Ask
Is your question about programming
We prefer questions that can be answered, not just discussed.
Provide details. Share your research.
If your question is about this website, ask it on meta instead.