echo "wow, TIL"|sed 's/(.)(.*)/\U\1\L\2/' → Wow, til
Вот тут у меня бомбануло от наркоманского седовсокого синтаксиса.
Чем конкретно этот пример лучше, что говноскрипт на питушоне(или любом другом языке) такого же размера?
https://stackoverflow.com/questions/4331851/sed-swapping-2-lines
sed -n ' # turn off default printing
/dog/{ # if the line matches "dog"
h # put it in hold space
:a # label "a" - the top of a loop
n # fetch the next line
/something/{ # if it matches "something"
p # print it
x # swap hold and pattern space
bb # branch out of the loop to label "b"
} # done with "something"
# if we're here, the line doesn't match "something"
H # append pattern space to hold space
x # swap hold and pattern space
s/\([^\n]*\)\n\([^\n]*\)$/\2\n\1/ # see below
x # swap hold and pattern space
ba # branch to the top of the loop to label "a"
} # done with "dog"
:b # label "b" - outside the loop
# print lines that don't match and are outside the pair
p # also prints what had been accumulating in hold space
' inputfile