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

I have this line in my linux shell script

sed '$a\' < file_a.txt 

I'm afraid to remove it from the code and cannot find out what it is for.

+5
source share
1 answer

It ensures that the output ends with a new line; cm:

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

As you can see with the previous code, the carriage return in the second example is not added, but one is added in the first example. Of course, if you delete the sed part, the output will be different, since the first echo statement does not have a carriage return.

+5
source

Source: https://habr.com/ru/post/1261934/


All Articles