Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- claudio
- antonio
- claudio
- michele
- claudia
- antonio
- claudio
- michele
- sed -e '1,/claudio/s/claudio/claudia/' nomi
- sed -e '0,/claudio/ s/claudio/claudia/' nomi
- awk
- $ awk 'NR==1,/claudio/{sub(/claudio/, "claudia")} 1' nomi
- claudia
- antonio
- claudio
- michele
- sed -n ':a;N;$bb;ba;:b;s/(claudi)o/1a/;p' file
- sed -n '1h;1!H;${g;s/(claudi)o/1a/;p;}' file
- sed -n ' # don't implicitly print input
- :a # label "a"
- N # append next line to pattern space
- $bb # at the last line, goto "b"
- ba # goto "a"
- :b # label "b"
- s/(claudi)o/1a/ # replace
- p # and print
- ' file
- sed -n ' # don't implicitly print input
- 1h # put line 1 in the hold space
- 1!H # for subsequent lines, append to hold space
- ${ # on the last line
- g # put the hold space in pattern space
- s/(claudi)o/1a/ # replace
- p # print
- }
- ' file
- $ awk '!f && /claudio/ {$0="claudia"; f=1}1' file
- claudia
- antonio
- claudio
- michele
- sed '$H;x;1,/claudio/s/claudio/claudia/;1d' <<IN
- claudio
- antonio
- claudio
- michele
- IN
- claudia
- antonio
- claudio
- michele
- sed --in-place=*.bak -e "1 h;1! H;$! d;$ {g;s/claudio/claudia/;}" -- nomi
- export chngFrom=claudio
- export chngTo=claudia
- sed --in-place=*.bak -e "1 h;1! H;$! d;$ {g;s/${chngFrom}/${chngTo}/;}" -- nomi
- sed -n '/claudio/{s/o/a/;bx};p;b;:x;p;n;bx' nomi
- sed -n ' # do not print lines by default
- /claudio/ { # on lines that match "claudio" do ...
- s/o/a/ # replace "o" with "a"
- bx # goto label x
- } # end of do block
- p # print the pattern space
- b # go to the end of the script, continue with next line
- :x # the label x for goto commands
- p # print the pattern space
- n # load the next line in the pattern space (clearing old contents)
- bx # goto the label x
- ' nomi
- sed -n '/claudia/{p;Q}'
- sed -n ' # don't print input
- /claudia/ # regex search
- { # when match is found do
- p; # print line
- Q # quit sed, don't print last buffered line
- { # end do block
- sed '/(claudi)o/!b;//s//1a/;:1;n;b1'
- sed '
- /(claudi)o/!b # Match the regex `claudio`. But in two parts `claudi` and `o`
- # and, for lines that do not match yet go to end (print).
- //s//1a/ # For one line that match the previous regex, change o to a.
- :1 # label to loop from now on.
- n # read next line (it gets auto printed).
- b1 # keep (only) printing to the end of file.
- '
- echo 'claudio
- antonio
- claudio
- michele' | sed -z 's/claudio/claudia/'
- claudia
- antonio
- claudio
- michele
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement