The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

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 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

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 01-16-2004
Registered User
 

Join Date: Jan 2004
Posts: 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  
Old 01-16-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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  
Old 01-16-2004
Registered User
 

Join Date: Jan 2004
Posts: 8
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
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0