![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| 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 07:24 AM |
| Too simple to search for | spudtheimpaler | UNIX for Dummies Questions & Answers | 3 | 10-21-2006 09:55 AM |
| Search & replace | videsh77 | Shell Programming and Scripting | 1 | 01-14-2005 04:10 AM |
| Simple Search and Replace - Revisited | Brandt | Shell Programming and Scripting | 1 | 04-23-2004 07:45 AM |
| search and Replace | mukeshannamalai | UNIX for Advanced & Expert Users | 4 | 09-14-2001 03:21 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
sweet! looks like voodoo to me, if you have the patience to explain what that script did, i would love to learn more about it.
thank you very, much!!!! |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
I'll try, but it's not real easy to explain...
s/^M\\$/^M\\/ changes cntl-m backslash to cntl-m backslash. The $ makes this happen only if the pattern is at end of line. This results in no change, but it set a success flag that can be tested later. That is how we know if we want to join the next line. H appends the pattern area to the hold area. The pattern area is where lines arrive as they are read. t test to see if that previous s commnand worked or not. If if did, we jump to the end of the script. Well not the last line. This means that we are finished with the current line. So we will read a new line and restart the script. x exchange. What I really want to do is to retrieve the hold area. Since we are here, the test failed. So we have a line that did not end with cntl-m backslash. s/\n//g That hold area that I just retrieved is a collection of lines that I want to join. So I delete the newlines. p print the line. Since there was a -n on the sed command line, no lines are printed automatically. s/.*// Remove all characters. This empties the pattern area. Thre is a d command, but it has side effects. I usually go with this as my delete. h copies pattern area to hold area. Now it's empty too. |
|
#10
|
|||
|
|||
|
i think i get the gist, i was able to use this script to clean up a few other anomalies as well.
thank you very much, i was to the point of asking the users if they really needed those records... which, invariably, they answer yes... you have saved me much headache. thanks again. |
|||
| Google The UNIX and Linux Forums |