Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • CSH Can't Handle Leading Zeroes

    Posted on

    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.)

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2026 Red Hat