Hi there!
I want to embed an awk script inside a shell script but I have trouble to do so as I don't know where to end a statement with a ; and where not.
Here's my script
#!/bin/sh
awk='
BEGIN {FS = ",?+" }
# removes all backspaces preceded by any char except _
function format() {
gsub("[^_]\b", "")
}
function getOptions() {
getline
format()
print
}
{
format()
if ($0 ~ /^SYNOPSIS$/ {
getOptions()
next
}
if ($0 /^[ \t]+--?[A-Za-z0-9]+/) {
print $0
}
}
END { print "\n" }'
path='/usr/share/man/man1'
list=$(ls $path)
for item in $list
do
echo "Command: $item"
zcat $path$item | nroff -man | awk "$awk"
done > opts
I'm using nawk by the way.
Thanks in advance