klr@decuac.dec.com (Kurt Reisler -- UNISIG Chairman) (07/01/91)
I am sure this has been asked before (therefore, it is a stupid question", but if I want to print out a percentage mark in a printf statement (as in printf "% changed"), what is the best (note, no reference to "proper", because I know better) to do it? Oh yes, I am still using version 3.0 PL44 (I think). Thanks in advance
Tom Christiansen <tchrist@convex.COM> (07/01/91)
From the keyboard of klr@decuac.dec.com (Kurt Reisler -- UNISIG Chairman): :I am sure this has been asked before (therefore, it is a stupid :question", but if I want to print out a percentage mark in a printf :statement (as in printf "% changed"), what is the best (note, no :reference to "proper", because I know better) to do it? Oh yes, I am :still using version 3.0 PL44 (I think). First, don't call printf if you don't need to. print "% changed"; works just fine. Also, be very wary of the common error of: $foo = <STDIN>; printf "you said $foo"; because what if they had a % in their string? Try !?%silly in the csh for a good time (but not from your login shell. :-). Finally, if you really want to use a literal %, it's as in C, you double it: printf "%% has changed %5d times", $count; --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."
klr@decuac.dec.com (Kurt Reisler -- UNISIG Chairman) (07/01/91)
Thanks to all who replied. It was truely a simple solution, "%%". It was too obvious to be obvious :-)