how can I ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how can I ?
# 1  
Old 05-17-2008
how can I ?

Hi all,

I've got some problems with editing a big configuration file .. its about 2k lines long.. anyway what I need is to place certain text to certain line number.. lets say I need to place "Something" on line 980 .. "something" else on line number 1500 and so on without tempering the rest of the configuration file ... I found somewhere this
Code:
head -981 conf.temp > conf.conf; echo "Email myemail@email.com" >> conf.conf; sed '4,$!d' <conf.temp >> conf.conf

it seems to work on one occasion but when I want to make another change in the configuration whole thing comes messed up, things appear double and so on ... any help ?

Thank you in advance ...
# 2  
Old 05-17-2008
Worst thread title ever. Even worse than "Help!" How can you what? I didn't read your post because of your lame ass title.
# 3  
Old 05-17-2008
0k Thank you for notifying me about the title .. go on and read not so lame titles ..
# 4  
Old 05-18-2008
First off this assumes you want to add a line of text so it becomes line #980, #1500
If what you mean is "backwards" from this, ie., becomes 981 and 1500, then put the print $0 at the top of the { } block instead of the bottom. I can't tell what you want.
Code:
awk '{  if (NR==980) { print "something"}
          if ( NR==1500) {prints "something else"}
          print $0
       } ' bigfile > biggerfile

# 5  
Old 05-18-2008
This question is posted here again:

https://www.unix.com/shell-programmin...#post302196382

Thread closed.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question