![]() |
| ||
| length of a variable! how can I limit the length of a variable??thanks |
| ||
| Re: length of a variable! Hey There, In bash (and similar shells) you can use read with the -n flag, like: read -n4 if you want to limit the variable input to 4 characters. If you want to just trim your variables, you can check the length of a variable by gettings the length value and running a simple if compare. so, if: var=12345 echo $var = 12345 echo ${#var} = 5 if [ ${#var} -gt 4 ] then bail fi Hope that helps :) , Mike |
| All times are GMT -4. The time now is 12:51 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC