3

For example, I want to make a command good night and this would look something like alias good night="many many many commands here". I tried this but, whitespace is not allowed. Is there any way I could accomplish this?

wjandrea
  • 14,236
  • 4
  • 48
  • 98

1 Answers1

10

This function should get you started:

good () {
    if [ -z "$1" ]; then
        echo "Perhaps you meant 'good night'?"
    else
        if [ "$1" = "night" ]; then
            echo "GOOD"
            echo "NIGHT"
            echo "good"
            echo "night"
            echo "etc"
        else
            echo "ERROR: strange time detected: $1"
        fi
    fi
}

Save it as, for example, good.sh, then source it:

. good.sh

good night now will execute various commands (replace the echo statements with whatever you want).

wjandrea
  • 14,236
  • 4
  • 48
  • 98
John N
  • 337