![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| get substr? | syamkp | Shell Programming and Scripting | 6 | 03-30-2008 11:08 PM |
| awk substr | colesga | Shell Programming and Scripting | 2 | 07-11-2007 04:43 AM |
| Substr | deepakwins | UNIX for Dummies Questions & Answers | 9 | 02-13-2007 09:58 PM |
| Using substr | Klashxx | Shell Programming and Scripting | 2 | 05-08-2006 04:58 AM |
| How to use awk substr ? | sabercats | Shell Programming and Scripting | 1 | 02-10-2006 04:01 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
awk or substr
i have a variable 200612
the last two digits of this variable should be between 1 and 12, it should not be greater than 12 or less than 1 (for ex: 00 or 13,14,15 is not accepted) how do i check for this conditions in a unix shell script. thanks Ram |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Nevemind; misread question.
Carl |
|
#3
|
||||
|
||||
|
Code:
[[ ${var#????} -lt 13 ]] && [[ ${var#????} -gt 0 ]]
....
|
|
#4
|
||||
|
||||
|
Quote:
Code:
var=200612
last2=${var#"${var%??}"}
if [ ${last2#0} -lt 1 ] || [ ${last2#0} -gt 12 ]
then
printf "INVALID %s\n" "$var" >&2
fi
|
||||
| Google The UNIX and Linux Forums |