[LUGOS] BASH: Test ali je vsebina spremenljivke znak

Petar Hitij hipe at sdf-eu.org
Fri Jun 4 18:12:34 CEST 2004


On Fri, Jun 04, 2004 at 03:45:06PM +0200, Gregor Gorjanc wrote:
> Zdravo!
> 
> Ali ima kdo kasno idejo, kako naj testiram v BASHU, ce je vsebina 
> spremenljivke znak? Sedaj sem poskusal s tem, pa ne gre.
> 
> if [ "$1" = "[:alpha:]" ]; then
> ...
> fi

#!/bin/bash

a="c"
b="1"

if [[ $a == [[:alpha:]] ]]
then
   echo "a: ok"
else
   echo "a: not ok"
fi

if [[ $b == [[:digit:]] ]]
then
   echo "b: ok"
else
   echo "b: not ok"
fi

-- 
hipe at sdf-eu.org
SDF-EU Public Access UNIX System - http://sdf-eu.org



More information about the lugos-list mailing list