home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15957 < prev    next >
Encoding:
Internet Message Format  |  1993-01-26  |  900 b 

  1. Path: sparky!uunet!munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!dstos3.dsto.gov.au!tumtum!sct
  2. Newsgroups: comp.unix.questions
  3. Subject: Re: How to recognize a csh var as a number?
  4. Message-ID: <1993Jan26.231002.165645@dstos3.dsto.gov.au>
  5. From: sct@tumtum (Shaun Troedson)
  6. Date: 26 Jan 93 23:10:01 CST
  7. References: <1jn3t3INN88b@haydn.crhc.uiuc.edu>
  8. Nntp-Posting-Host: tumtum.dsto.gov.au
  9. X-Newsreader: TIN [version 1.1 PL8]
  10. Lines: 15
  11.  
  12. Timothy Tsai (ttsai@crhc.uiuc.edu) wrote:
  13. : I am reading string values into a csh variable.  Depending on whether each
  14. : string represents a number or not, I want to do certain things.  How do I test
  15. : to see if the variable string is a number or not?
  16.  
  17. I think this works but its a mess:
  18.  
  19. echo @ var = $var | csh -t >& /dev/null
  20.  
  21. The status variable will now contain 1 if 'var' is alpha, 0 if it is num.
  22. There's probably a less round-about way.
  23.  
  24. regards
  25.  
  26. sct.
  27.