Sed and regular expressions
Ok, it sounds a little "newbieish"...
I'm trying to create a fortune db. I have a looong text file, with every citation separated by a blank line. Then, my problem is to use sed to substitute every blank line in the file with a percent symbol. I tried in the following way : sed 's/\n/%/gi' ~/source (redirecting it to "~/dest" to obtain the db). I've tried other regexp, but no-one did work. So, the question is, what's the right one? :confused: Thank you in advance for any help given. |
Re: Sed and regular expressions
Quote:
Fortunately, you don't have to deal with them, since you really don't want to replace the newline, you just want to add a percent sign on every blank line. The regex for a blank line is /^$/ i.e., the beginning of the line followed immediately by the ending of the line. So you want this: s/^$/%/ as your regex. Cheers-- Charles |
Thank you very much, it works perfectly!
|
All times are GMT -5. The time now is 02:24 PM. |