![]() |
|
|
|
|
|||||||
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. Shell Script Page. |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 Thank you in advance ... |
| Forum Sponsor | ||
|
|
|
|||
|
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
|
|
|||
|
|
|||
| Google UNIX.COM |