What does this mean in Linux sed '$a\' a.txt

我与影子孤独终老i 提交于 2021-01-27 06:08:42

问题


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.


回答1:


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

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

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.



来源:https://stackoverflow.com/questions/41343062/what-does-this-mean-in-linux-sed-a-a-txt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!