sed – need an example for ”\digit”
Michael Welle
mwe012008 at gmx.net
Sun Feb 26 10:43:15 UTC 2012
Hello,
Johnny Rosenberg <gurus.knugum at gmail.com> writes:
[...]
> By the way, I have an almost similar question, let's call it a follow
> up question ant let's how it's not as stupid as the last one…
>
> This works as expected:
> ~$ echo "This is a short sentence" | sed 's/[^ ]* [^ ]* //'
> a short sentence
> ~$
>
> However, I tried to make it somewhat shorter, by using the {digit}
> syntax, but I failed again… I am not sure how to group ”[^ ]* ” in a
> proper way. This does not work:
> ~$ echo "jag är en ko" | sed 's/\([^ ]* \){2}//'
> jag är en ko
> ~$
>
> What I'm trying to do is to remove the two first words from a
> sentence, if that wasn't obvious. This should work no matter how many
> words there are in the sentence.
well, depending on your shell and your sed you need to quote the { and
the }.
Regards
hmw
--
biff4emacsen - A biff-like tool for (X)Emacs
http://www.c0t0d0s0.de/biff4emacsen/biff4emacsen.html
Flood - Your friendly network packet generator
http://www.c0t0d0s0.de/flood/flood.html
More information about the ubuntu-users
mailing list