Problem with shell script

Maarten Litmaath maart at cs.vu.nl
Wed May 3 07:15:02 AEST 1989


bause at exunido.uucp (Falko Bause) writes:
\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

1) For EVERY line you start up 2 programs, to skip the preceding lines! :-(
   Solution: use the BOURNE shell for scripts; see Kenneth Almquist's article.
2) If you're using csh's `@' feature, why not do it all the way?

	@ e--

3) Can you say `indentation'?
4) What in G*d's name are you trying to do inside awk's first argument?!
   Trying if inserting some more quotes will help you out?
   Backquotes are used for COMMAND SUBSTITUTION; is $f a command?
   (That's rhetorical.)
   What you probably intended:

	   awk /"$f"/'{print int($1/48), "", ""}' skriptyyz
					 ^^^^^^
					 Why?
   Some remarks:

	- if you surround $f by double quotes, the SHELL won't evaluate its
	  contents, but don't forget AWK knows some meta-characters too!
	  What about a line solely consisting of `*'? The problem is awk
	  expecting a regular expression, while you probably want a LITERAL
	  match. I haven't got a solution at hand for this one.
	- The $1 is an AWK variable; the shell won't mess with it, since
	  it's inside single quotes.
-- 
 "If it isn't aesthetically pleasing, |Maarten Litmaath @ VU Amsterdam:
  it's probably wrong." (jim at bilpin)  |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.unix.wizards mailing list