Re: Beginner : delete a line with repeating pattern

Tim Chase <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
> echo "house boat car, , , ," | sed '/, \{4\}$/d' this works (4
> commas in a row)

I don't think that this does what you expect it to.  It doesn't find 4 commas in a row, if finds a comma followed by 4 spaces at the end of the line, and deletes the whole row if it finds that.

> How do I deal with 
> echo "house boat car, , , , $"    a comma followed by a space 4 times. I tried the [ ] but it didnt work
> echo "house boat car, , , ," | sed '/[, ]\{4\}$/d'
> echo "house boat car, , , , " | sed '/, \{4\}$/d'

I *think* what you want is 4 "comma + zero or more spaces" which
should be something like

  echo "house boat car, , , , " | sed '/\(, *\)\{4\}$/d'

If you just want to remove the commas/spaces while keeping the first
value, you can do

  echo "house boat car, , , , " | sed 's/\(, *\)\{4\}$//'

-tim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.