|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Hi there,
may someone easily help me on this : I want to insert a text in a specific line number like : linenumb2start=`cat memory_map.dld | nl -ba | egrep -i "label" | cut -f1` line2insert=`expr $linenumb2start + 2` and now I need to replace something like {} with {comment} at $line2insert. The line actually is : .appdata {} and no identifier can be added to use it for search and substitution. Of course, appdata and {} are already used as well in several locations. Therefore, I really need to use the line number. Do you have a solution using sed or awk ? ![]() Thanks, homefp |
| Sponsored Links |
|
|
|
|||
|
Thanks a lot !!!
This works perfectly as expected. Is there as well such a single sed command to remove several lines starting from my "label" line after all ? May be something like : sed '/label/{d.....n;d...}' < filein > fileout ; mv fileout filein Thanks again, homefp |
|
|||
|
In fact one line command only to replace sequential sed commands as :
sed '/labe/{n;n;d;}' < filein > fileout; mv fileout filein sed '/label/{n;d;}' < filein > fileout; mv fileout filein sed '/label/d' < filein > fileout; mv fileout filein thanks, homefp ![]() |
|
|||
|
this was just to finalize my need...
I was wondering if in a single sed command it would be possible to remove several lines starting from my label : the following : sed '/label/{N;N;d;}' < input > output is only removing the second line after label, isn't it ? But if I want to remove in one shot several lines, having only my label as reference, how should I write my sed command ? In fact, I would like to replace the 3 lines described in my previous post : sed '/labe/{n;n;d;}' < filein > fileout; mv fileout filein sed '/label/{n;d;}' < filein > fileout; mv fileout filein sed '/label/d' < filein > fileout; mv fileout filein with only one. Thanks, homefp |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding a columnfrom a specifit line number to a specific line number | Ezy | Shell Programming and Scripting | 2 | 05-12-2008 09:29 AM |
| remove single-line comment | Icy002 | Programming | 3 | 04-09-2006 09:30 AM |
| how to insert a line number on every line | mopimp | UNIX for Dummies Questions & Answers | 3 | 03-25-2006 01:35 PM |
| Need to add a comment line in a text file | orakhan | Shell Programming and Scripting | 2 | 09-22-2005 09:36 PM |
| sed to have defined positionning on line | homefp | Shell Programming and Scripting | 10 | 04-29-2002 09:42 AM |