text - Using sed to change only consecutive repeated letters -
using sed, how change letter 'a' 'a' if appears repeated 2 or more consecutive letters. example, from:
galaxy ear aardvak haaaaaaaaa into
galaxy ear aardvak haaaaaaaaa
you can using groups. if have file:
$ cat galaxy ear aardvak haaaaaaaaa ulaanbaatar you can use sed command:
$ sed 's/\(.\)\1\{1,\}/\u&/g' galaxy ear aardvak haaaaaaaaa ulaanbaatar what happen here? if have char, "packed" in group (\(.\)), , group (\1) repeats 1 or more times (\1\{1,\}), replace matched part (&) uppercased version (\u&).
Comments
Post a Comment