Skip to content
Advertisement

How to add a string to line 13 in my text file

I have a very large text file that is difficult to open in text editors.

Lines 12 – 15 are:

JavaScript

I would like to add:

3 196 to line 14 and then have a blank line between 3 196 and Atoms like it is currently. I tried:

JavaScript

But it did not seem to change anything. Anyone know of how I can do this?

Advertisement

Answer

Normally, sed only writes out the changes. It does not modify the file.

If you want the input file to be modified, you can use GNU sed -i:

JavaScript

Before:

JavaScript

After:

JavaScript

Note: If you want it after line 13 instead of 14, change 14 to 13 in your code. Similarly, if you wanted 3 196 instead of <3 196>, change <3 196> to 3 196 in your code.

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