array=("pippo pluto topolino") value=pluto [[ " ${array[@]} " =~ " ${value} " ]] && echo "YES" || echo "NO" if [[ " ${array[@]} " =~ " ${value} " ]]; then echo trovato; fi pippo="ciao" [[ $pippo = "ciao" ]] && echo "1yes" [[ "ciao" = "ciao" ]] && echo "2yes" x="valid" if [ "$x" = "valid" ]; then echo "x has the value 'valid'" fi [[ "$x" = "valid" ]] && echo "x is valid" [ "$x" == "valid" ] && echo "x has the value 'valid'" [ "$x" == "valid" ] && echo "i am valid" || echo "i am invalid"
Friday, June 14, 2019
bash comparison and validation of string
trying to understand Bash syntax is really wasted time.... just copy/paste working examples
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment