Skip to content
Advertisement

Sed is truncating first character if it is starting with “v” while appending in file

I am stuck in one of my production code where I am trying to append some content at the start of file and if the content which I want to append is starting with “v” , its getting truncated.

Steps to reproduce:

JavaScript

Output:

JavaScript

Desired Output:

JavaScript

Advertisement

Answer

Your use of the backslash is wrong. Check this:

JavaScript

Your escaping leads to the following sed command:

JavaScript

v is a special char: vertical tab, which is not visible on your terminal.

The simple solution is to not escape at all, it’s simply not needed when interpolating variables into a double quoted string:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement