这在Linux sed'$ a \'a.txt中是什么意思 [英] What does this mean in Linux sed '$a\' a.txt

查看:82
本文介绍了这在Linux sed'$ a \'a.txt中是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Linux shell脚本中有这一行

I have this line in my Linux shell script

sed '$a\' < file_a.txt

害怕将其从代码中删除,却找不到它的作用.

Afraid to remove it from the code and cannot find out what it is for.

推荐答案

确保输出以换行符结尾;看到:

It makes sure the output will end with a newline; see:

echo -ne test | sed '$a\'
# same output as:
echo test | sed '$a\'

如您在前面的代码中所见,在第二个示例中未添加回车符,但在第一个示例中已添加了回车符.当然,如果删除 sed 部分,则输出将有所不同,因为第一个 echo 语句没有回车符.

As you can see with the previous code, a carriage return isn't added in the second example but one is added in the first example. Of course, if you remove the sed part, the output will be different since the first echo statement has no carriage return.

这篇关于这在Linux sed'$ a \'a.txt中是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆