Problem with shell script

Falko Bause bause at exunido.uucp
Fri Apr 28 22:15:52 AEST 1989


Trying to go deeper into UNIX, i've a problem with the
substitution of variables.
I've a file named skriptyyz with line numbers in the first
collumn (produced by cat -n) and a file named words
which contains the words for generating a register.
The following shell script should generate this register:

echo REGISTER
echo " "
rm -f skriptyyz
cat -n $1 > skriptyyz # $1 == "text"
set d = `wc -l words`
set e = $d[1]
while ($e)
set f = "`tail -$e words | head -1`"
echo $f 
awk '/"""`$f`"""/ {print (int('$1'/48)), "", "" }' skriptyyz #?? not correct
                                  # page length is exactly 48
@ e = $e - 1
end

The problem is calling awk.
awk shall use the pattern in the variable f.
Unfortunately f can also contain patterns like "$ber",
which should be interpreted as the string (!) "$ber"
and not as the variable ber.

What is the right syntax for calling awk and how is
variable substitution performed?
And is there an easier and faster way in generating a register?

Thanks Falko



More information about the Comp.unix.wizards mailing list