Results 1 to 2 of 2
Hello
I've created (as a homework) to create as many folders as told but I still need to check if the variable is a number or not :
Code:
#!/bin/sh
...
- 04-30-2011 #1Just Joined!
- Join Date
- Apr 2011
- Posts
- 1
Checking a variable
Hello
I've created (as a homework) to create as many folders as told but I still need to check if the variable is a number or not :
Question : how do I check that nmbr is a number or something else ? thanks in advance.Code:#!/bin/sh echo "Veuillez saisir un nombre"; read nmbr nmbrf=$nmbr while [ $nmbrf -gt 0 ] do mkdir -p "foo$nmbrf" nmbrf=`expr $nmbrf - 1` echo "$nmbrf" done
- 05-01-2011 #2
Homework questions are not allowed on these forums as per the rules:
http://www.linuxforums.org/forum/lin...ums-rules.html
As a bit of a hint: you can treat $nmbr as a string. If the string was also a valid number, what properties would it have?DISTRO=Arch
Registered Linux User #388732


