Re: newbie question: how to convert str to int in c-shell?
- From: "neo" <neoedmund@xxxxxxxxx>
- Date: 31 Oct 2006 03:27:05 -0800
Chris F.A. Johnson のメッセージ:
On 2006-10-31, neo wrote:why?
hi, i am a newbie in shell. i am using c shell.
If you want to write a script, don't use csh.
if i can chose, i'd use python. yes, ...maybe i can chose.
it works, thanks.
say convert a argument to int.
if it is not a int , some flag or message should be got.
how to do so in a neat way?
A simple test for a numeric argument, in a standard shell is:
case $n in
*[!0-9]*) printf "%s\n" "Not a number" ;;
esac
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.
- Follow-Ups:
- Re: newbie question: how to convert str to int in c-shell?
- From: Ed Morton
- Re: newbie question: how to convert str to int in c-shell?
- References:
- newbie question: how to convert str to int in c-shell?
- From: neo
- Re: newbie question: how to convert str to int in c-shell?
- From: Chris F.A. Johnson
- newbie question: how to convert str to int in c-shell?
- Prev by Date: Re: newbie question: how to convert str to int in c-shell?
- Next by Date: Re: How can I FTP a file from one UNIX box to other UNIX box using xcomtp.
- Previous by thread: Re: newbie question: how to convert str to int in c-shell?
- Next by thread: Re: newbie question: how to convert str to int in c-shell?
- Index(es):
Relevant Pages
|