Getting csh to preserve trailing blanks from backquoted commands.

Joe Smith jms at tardis.Tymnet.COM
Sat Sep 29 05:53:40 AEST 1990


In article <1243 at romana.Tymnet.COM> I ask:
>How do you pad a csh variable to specific length using trailing blanks?

Answer: Use double quotes when setting the variable, and when referencing it.

Part of it was a blind spot in my thinking.  I had convinced myself that
	set who="`expr substr '$USER        ' 1 8`"
would not work since the $USER was inside single quotes.  That was wrong.
Due to the surrounding double quotes, "'" is treated as an apostrophe; just
another printing character at the time variable substitution takes place.
-- 
Joe Smith (408)922-6220 | SMTP: jms at tardis.tymnet.com or jms at gemini.tymnet.com
BT Tymnet Tech Services | UUCP: ...!{ames,pyramid}!oliveb!tymix!tardis!jms
PO Box 49019, MS-C41    | BIX: smithjoe | 12 PDP-10s still running! "POPJ P,"
San Jose, CA 95161-9019 | humorous dislaimer: "My Amiga 3000 speaks for me."



More information about the Comp.unix.shell mailing list