Subject: Re: reading date in csh script, text to numbers
To: john <jkaufman@home.com>
From: Peter Seebach <seebs@plethora.net>
List: netbsd-help
Date: 01/22/2001 23:45:01
In message <000f01c084fb$91fe6540$41634718@ssdt1.sk.wave.home.com>, "john" writ
es:
>I am new to netBSD, and unix in general. My
>question is about the csh.

Please don't program in csh.  It's ugly.

>I have tried to set
>date in a variable.

>set month =3D date '+%m'
>echo $month

This will not work.

>When I do this, I get a syntax error.

Yes, you do.

How is the shell supposed to guess what you want "month" to be set to?
You want it to be set to "the output of running the command date with
the argument +%m".

The way you tell csh to use "the output of" is to enclose a command in
backticks (`).  Thus, you might try
	set month = `date '+%m'`

>Also, is there a way to
>convert text to a numeric value directly from=20
>one or more of the shell commands, or is the
>only way to do it by writing a c program?

Define "convert text to a numeric value".  For most purposes, shell-like
languages will treat something as numeric if you use it in a numeric context.

Once again, though, I *strongly* urge you to use ksh, not csh, for scripting.
(On NetBSD, /bin/sh is actually quite viable.)  csh is an abysmal scripting
language.

-s