46 lines
687 B
Awk
46 lines
687 B
Awk
|
|
#!/usr/bin/awk -f
|
||
|
|
|
||
|
|
#
|
||
|
|
# Define separators
|
||
|
|
#
|
||
|
|
BEGIN{
|
||
|
|
#
|
||
|
|
# The field separator is a newline
|
||
|
|
#
|
||
|
|
FS = "\n"
|
||
|
|
|
||
|
|
#
|
||
|
|
# The record separator is two newlines since there's a blank line between
|
||
|
|
# contacts.
|
||
|
|
#
|
||
|
|
RS = "\n\n"
|
||
|
|
|
||
|
|
#
|
||
|
|
# On output write a line of hyphens on a new line
|
||
|
|
#
|
||
|
|
ORS = "\n----\n"
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
#
|
||
|
|
# Show where the "beginning of buffer" is
|
||
|
|
#
|
||
|
|
sub(/\`/, "[")
|
||
|
|
|
||
|
|
#
|
||
|
|
# Show where the "end of buffer" is
|
||
|
|
#
|
||
|
|
sub(/\'/, "]")
|
||
|
|
|
||
|
|
#
|
||
|
|
# Show where the start and end of "line" are
|
||
|
|
#
|
||
|
|
sub(/^/, "{")
|
||
|
|
sub(/$/, "}")
|
||
|
|
|
||
|
|
#
|
||
|
|
# Print the buffer with a record number and a field count
|
||
|
|
#
|
||
|
|
print "(" NR "/" NF ")", $0
|
||
|
|
}
|