我有一个脚本来转换文件的数据,为了更有效地工作,我想改变内存中的数据,然后将其转储到文件。 Supose我想修改一个包含这个文件的文件:
> This is a line > this is other line
我用一个sed命令用'#'replace'>'符号:
transform_output=$(eval "sed ${sed_args[@]} $file" 2>&1) echo -e $transform_output
我得到的输出:
# This is a line # this is other line
而不是输出我想要的是:
# This is a line # this is other line
(我想获得的文件将是):
#ADDED LINE# # This is a line # this is other line
提前致谢
引用用于防止在空白处分词:
echo -e "$transform_output"
用另一个回显分组命令:
{ echo "#ADDED LINE#"; echo -e "$transform_output" } > file