我是一名有用的助手,可以为您进行翻译。以下是需要翻译的内容:
我得到输出:
感谢您的提前帮助。
我有一个脚本,可以转换文件的数据。为了更有效地工作,我想在内存中修改数据,然后将其转储到文件中。 假设我想修改包含以下内容的文件:
> This is a line
> this is other line
我使用sed命令将'>'符号替换为'#':
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#”的变量开头添加一行并将其保存到文件中?
(我想要获得的文件应该是):
#ADDED LINE#
# This is a line
# this is other line
感谢您的提前帮助。