PDA

View Full Version : How to write something on a text file on a certain line?



Bong.Da.City
17th December 2010, 19:54
This is how i write something on text file:

{system("echo \"Hello\" > /home/$USER/.config/Wallch/Checks/language_selection");

But how to write something on a certain line without changing the others?
For example how can i write "Hello" on the third line of my text file without changing the first line... ?

Bong.Da.City
17th December 2010, 22:01
ok solved:
sed -i "4i\Hello" file_here

while 4 is the line :)