![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Inserting a String in a file header. | Hari123 | Shell Programming and Scripting | 3 | 05-14-2008 10:00 AM |
| inserting line?? | anj | UNIX for Dummies Questions & Answers | 7 | 11-03-2007 12:18 PM |
| sed - Replace Line which contains the Pattern match with a new line | kousikan | Shell Programming and Scripting | 2 | 03-24-2007 07:24 AM |
| Inserting character in every line | dakid | Shell Programming and Scripting | 1 | 08-25-2006 08:54 AM |
| inserting a String in the file(s) | 2tbee | Shell Programming and Scripting | 4 | 04-11-2006 06:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Inserting new line after match of a fixed string
Hi,
I have a file which contains many occurances of a string say "hellosunil". I want to insert a newline charcater after all the "hellosunil" strings in the file. trying to use sed, sed -e 's/hellosunil/\\nhellosunil/g' file1 sed help says u cannot substitute a regular expression using new line char. so the above thing does not work? how can i achieve this using sed or any other command. |
|
||||
|
Re: Inserting new line after match of a fixed string
Quote:
Code:
awk '{gsub(/hellosunil/,"\nhellosunil");print}'
|
|
||||
|
I tried the foll. command:
awk '{gsub(/<eCRMver1:Consumer>/, "\n<eCRMver1:Consumer>"); gsub(/<\/eCRMver1:message>/, "\n<\/eCRMver1:message>");print}' $input_file > $tem p_output_file1 ERROR: awk: 0602-581 The result <?xml version="1.0" of the gsub function cannot be longer than 10,239 bytes. The input line number is 1. The file is /appl/ecrmhome/gb53/VSC.xml. The source line number is 1. my VSC.xml is 35000 (and it can be much more ???) Please suggest. |
|
||||
|
taking the entire file in a variable and applying sed WORKS...
total_xml_msg=`cat $input_file` echo $total_xml_msg | sed 's/<eCRMver1:Consumer>/\ <eCRMver1:Consumer>/g' > $temp_output_file1 good for the time being... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|