繁体   English   中英

Linux Shell脚本:将文件和字符串一起写入另一个文件

[英]Linux Shell Script: Writing file and string together to another file

这是我的代码是bash脚本:

for string in $LIST
do
echo "$string" >> file
grep -v "#" file1 >> file
done

“file1”只包含一个值,并且该值会迭代地更改。

我在“文件”中得到的结果是:

a
1
b
2
c
3

但是,我想要这个:

a 1
b 2
c 3

提前致谢。

for string in $LIST
do
  echo "$string" $(grep -v "#" file1)
done > file

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM