Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Thank you. Rremoving all duplicates isn't what I want to do; e.g., "command" should stay "command" but "NNAAMMEE" should become "NAME" is there a way to use sed with 's/(.)\1/\1/g' but only for double-capitals? Commented Sep 10, 2013 at 23:43
  • @JonSmith - you could take the first example and remove the a-z bit from the set of characters. sed 's/\([A-Z]\)\1\+/\1/g' Commented Sep 10, 2013 at 23:45
  • To do it in just headers, add /^[A-Z]/ - sed '/^[A-Z]/s/\(.\)\1/\1/g' Commented Sep 11, 2013 at 1:28
  • Can you explain what the parenthesis are for? How is [A-Z] different from ([A-Z]) Also, what is the + operator for? The \1 is for pattern matching, correct? Commented Sep 11, 2013 at 5:26
  • @slm I knew only basic of sed, this answer is amazing, but can you please explain. like what is meaning of \1 Commented Sep 12, 2013 at 16:13