Re: I'm an idiot and sed proves it...
Aaron Denney wrote:
> dwarf@polaris.net wrote:
> > For the tabs, I try the following:
> >
> > sed -e 's/'\t'/ /g' <infile >outfile
> >
> > Which very cleanly places every t in the document with a space!??
> >
> > For the hyphonation I try:
> >
> > sed -e 's/-'\n'//g' <infile >outfile
> >
> > and although the file gets slightly smaller (I didn't try to find out just
> > what had been removed) none of the hyphonated text is corrected.
>
> This isn't quite the appropriate venue for such questions, as it is
> a general unix/sed question and not very specific to Debian. In the
> future try the newsgroup comp.unix.programmer or comp.unix.questions.
Lignten up :) Dale provides immense assistance to this list; he deserves
a little slack.
> Your problem is that the inner quotes don't add another level quoting, but
> take away another level of quoting. To be a little clearer:
>
> > sed -e 's/'\t'/ /g' <infile >outfile
> ^^ ^^^^ are the quoted parts.
>
> The \t is not quoted, but is interpreted by your shell, which replaces the \t
> with an actual t. If you take out the inner quotes, it should work:
> sed -e 's/\t/ /g' <infile >outfile
>
> This will pass an actual \t to sed, which will interpret it as a tab characte
r.
Actually, no. Bash requires $'\t' for the literal insertion of
an escaped character (and no, I didn't know. I looked it up :))
So your first example, Dale, becomes
sed -e s/$'\t'/' '/g < infile > outfile
and the second
sed -e s/-$'\n'//g < infile > outfile
Note the lack of surrounding quotes!
Stephen
---
"Normality is a statistical illusion." -- me
--
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: