Use awk with a flag to trigger the print when necessary:
$ awk '/abc/{flag=1;next}/mno/{flag=0}flag' file
def1
ghi1
jkl1
def2
ghi2
jkl2
How does this work?
/abc/ matches lines having this text, as well as /mno/ does.
/abc/{flag=1;next} sets the flag when the text abc is found. Then, it skips the line.
/mno/{flag=0} unsets the flag when the text mno is found.
The final flag is a pattern with the default action, which is to print $0: if flag is equal 1 the line is printed.
For a more detailed description and examples, together with cases when the patterns are either shown or not, see How to select lines between two patterns?.
Use
sed '/#start/,/#end/replace_command'
For example, if the file is called myconfig, and you want to replace "allow" with "deny" in that section, you could say
sed '/#start/,/#end/s/allow/deny/' myconfig
example
sed -i -r "/<elasticConfig>/,/<\/elasticConfig>/s,<enabled>.+</enabled>,<enabled>false</enabled>," file.xml
Ce tuto est bien fait
Mais j'ai un peu de mal avec awk : pour des tâches simple je m'en sors avec cut, et pour des tâches plus complexes je passe à un vrai langage de scripting comme python
| awk '{total = total + $1}END{print total}'
find . ! -newer /tmp/file2015 -exec ls -l --block-size=M {} \; |cut -d' ' -f5|sed 's/M//'| awk '{total = total + $1}END{print total}'
Relink, je les avais perdu :
Part 1 : http://www.linuxjournaldigital.com/linuxjournal/201109#pg94
Part 2 : http://www.linuxjournal.com/content/gnu-awk-41-teaching-old-bird-some-new-tricks-part-ii