Reputation: 73
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.
Upvotes: 7
Views: 1144
Reputation: 7517
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.
Upvotes: 6