shell

Bash Scripting, ejemplo con arrays

### fichero lenguajes.sh
#!/bin/bash
arr=( "espanyol#hola" "ingles#hello" "frances#bonjour")
len=${#arr[*]}
i=0
while [ $i -lt $len ]; do
   lenguaje=$(echo ${arr[$i]} | cut -d"#" -f1 2>/dev/null)
   if [ "$lenguaje" == "$1" ]; then
     echo ${arr[$i]} | cut -d"#" -f2
   fi
   i=$(expr $i + 1)
done
$ sh lenguajes.sh espanyol
hola
$ sh lenguajes.sh ingles
hello