![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| 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 in Ksh | DeepakXavier | Shell Programming and Scripting | 9 | 05-28-2007 08:11 AM |
| sed search and replace | d__browne | UNIX for Dummies Questions & Answers | 7 | 04-26-2006 09:46 AM |
| how to search for a str and replace it.. | sekar sundaram | Shell Programming and Scripting | 6 | 12-29-2005 06:11 PM |
| search and Replace | mukeshannamalai | UNIX for Advanced & Expert Users | 4 | 09-14-2001 06:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi folks,
I need to search and replace specific text in a file and replace it. I have a text file that does not have any newlines or carriage returns. All newlines have been removed. Here is what I need to do. Find the exact string “DH” (quotes included) and replace it with \n”DH” (basically putting a newline in front of all occurances of “DH”) I have tried using sed… sed 's/\<"DH"\>/\"DH"/g' DHt.txt > DH2.txt When I tried the sed example the output has nothing in it. I think this is because there are no newlines or carriage returns. And tr command… tr -s '["DH"]' '[\\012"DH"]' < DHu.txt > DHt.txt This replaces anything with DH in it and the newline is not added, it adds \012. It needs to to find only “DH” Now I’m pretty new this type Unix commands so my syntax could easliy be wrong . Thank all in advance, Joaquin |
|
||||
|
I tired the insert character and earch and replace it with \n, but that speacial character could be in the file and I cannot replace it.
I also tried vi and then typing :%s/"DH"/^M"DH"/g But I must have done something wrong, when I type in the line it says "what" Is there a way to type it in the command line? Thanlks for the help eveyone, Joaquin |
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|