Re: I'm an idiot and sed proves it...
On Wed, 26 Nov 1997, Dale Scheetz wrote:
> And this may allow me to deal with the hyphons at the end of the lines. I
> can do one pass through sed replacing new lines with \n, and then make
> another pass editing out all the '-\n'. I am still left with the problem
> of converting all the other '\n' strings back into newline characters. If
> I knew this, I could put that into the original search, so I'm left with
> trying to search for a newline.
here's a first-attempt, draft solution in perl:
#! /usr/bin/perl
$/=""; # read input in paragraphs, not lines.
while (<>) {
s/\s+\n/\n/; # remove trailing whitespace
s/(\w+)-\n(\w+)/$1$2/g; # de-hyphenate
print
}
you'll probably need to hack it a bit to do everything you need. enjoy.
yes, i know it's perl and not sed. i got converted some time ago :-). i
used to do this kind of stuff with sed and awk and cut and all the other
text processing tools. now i only use them for quick one-liners at the
shell prompt and use perl for scripting. perl makes this kind of thing a
lot easier (and the extended regexps are cool too).
craig
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: