bash esac problem

H

homecrow

Jungspund
Hey,

ich weiß nicht wie ich das problem hier lösen kann:

Code:
#!/bin/bash

func()
{
    echo 'hello world'
}

select abm in 'Print hello world' 'do nothing' ; do
    case $REPLAY in
        1 ) func() ;;
        2 ) echo 'do nothing' ;;

    esac
    if [[ -n ${abm} ]]; then
        echo 'you select:' ${abm} 
        break
   fi
done

Wie zu sehen möchte ich ne auswahl haben und damit dann eine definierte funktion starten, ich könnte die funktionen zwar in ne externe datei auslagern und diese dann so aufrufen
also
Code:
1 ) exec ~/print_hello_world.sh ;;
funktioniert, aber ich würde gerne die definierte funktion innerhalb des scripts starten, nur leider weiß ich nicht wie ich das anstellen soll.

Hoffe hier kann mir jemand helfen.
 
So:
Code:
func()
{
    echo 'hello world'
}

select abm in 'Print hello world' 'do nothing' ; do
    case $REPLY in
        1) func ;;
        2) echo 'do nothing' ;;
    esac
    if [[ -n ${abm} ]]; then
        echo 'you select:' ${abm} 
        break
   fi
done

oder so:
Code:
func()
{
    echo 'hello world'
}

select abm in 'Print hello world' 'do nothing' ; do
    case "$abm" in
        'Print hello world') func ;;
        'do nothing') echo 'do nothing' ;;
    esac
    if [[ -n ${abm} ]]; then
        echo 'you select:' ${abm} 
        break
   fi
done
 

Ähnliche Themen

Telefoninterview (Wie sich auf Bash-Shell-Fragen vorbereiten?)

ip6tables Problem

continue in Schleife einbauen

verzeichniss suche funktioniert nicht

Shellskript - Fehler in Cron

Zurück
Oben