CSH Can't Handle Leading Zeroes
No action needed on this, but I thought RHEL users would want to know: Unlike Unix (e.g. Mac OS X), RHEL's implementation of CSH barfs on leading zeros when reading a number from a text file into a numeric CSH variable. For example, if a file contains the text "00123", then the following statement:
@ myNum = cat $data_dir/mynum.txt
will give you the number 123 if you are running the CSH file under Unix, but Red Hat will generate a "Badly formed number" error. You can make it work in Red Hat by trimming leading zeroes, like so:
@ myNum = cat $data_dir/mynum.txt | sed 's/^0*//'
(However, that might fail if the number is actually zero, so watch out for that.)
Responses
A leading zero indicates a number in octal representation, refer to Wikipedia
Using 00918 leads to bad format:
$ cat a
00918
$ @ z = `cat a`
@: Badly formed number.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
