Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/awk -f
- # Tema d'esame 07/02/2003 A (www.labinf.polito.it/whitone/index.php?summ=SO)
- # Uso: awk -f paragrafi.awk testo.txt
- # 15/08/2012 - BNCRCR
- BEGIN {
- paragrafi = 1 # Se ho solo una riga ho comunque un paragrafo
- precedente_vuota = 0
- }
- # Pattern che identifica una riga vuota
- /^$/ {
- if (!precedente_vuota)
- paragrafi++
- precedente_vuota = 1
- }
- # Pattern che identifica una riga con almeno un carattere
- /./ {
- precedente_vuota = 0
- }
- END {
- print paragrafi
- }
- # == testo.txt ==
- # ciao, sono una linea di testo che delimita un paragrafo
- #
- #
- # io sono un altro paragrafo
- # io invece no
- #
- # quindi alla fine ho tre paragrafi. ciao.
Advertisement
Add Comment
Please, Sign In to add comment