![]() |
|
|
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 |
| How to search and replace text in same file | Vrgurav | Shell Programming and Scripting | 1 | 04-25-2008 07:20 AM |
| automating file search and replace text | ommatidia | Shell Programming and Scripting | 3 | 02-28-2008 04:40 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| search and replace the whole line | Jartan | Shell Programming and Scripting | 17 | 09-25-2007 02:58 PM |
| How do you search and replace a text with markerA that end with markerB | drone | Shell Programming and Scripting | 1 | 06-19-2003 10:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Search and replace multi-line text in files
Hello
I need to search for a mult-line text in a file exfile1 and replace that text with another text. The text to search for is in exfile2 and the replacement text is in exfile3. I work with kornshell under AIX and need to do this with a lot of files. (the file type is postscript and they need to be edited before printing with our old card plotter that cannot manage bitmaps) exfile1: asdasdasdasd asdasdasdasd abc def ghi sdasdasdasda asdasdasdada exfile2: abc def ghi exfile3: jkl mno pqr I have tried with sed with little sucess. Any ideas? |
|
||||
|
I have tested a little more and I have a problem.
All the files are bigger than 10,239 bytes and cannot be processed by the awk function. Error: "awk: 0602-534 Input line xxxxxxxx cannot be longer than 10,239 bytes." Any idea to solve this problem? Best regards marz |
|
|||||
|
This is the same idea as before but using perl instead of awk... Code:
perl -e ' undef $/; open(SEAR, "< exfile2"); open(REPL, "< exfile3"); open(INFI, "< exfile1"); open(OUTF, "> exfile4"); $sear = <SEAR>; $repl = <REPL>; $data = <INFI>; $data =~ s/$sear/$repl/g; print OUTF $data; ' |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|