Multi line alias in bash

You have a couple of issues here

  1. unlike in csh, in bash (and other Bourne-like shells), aliases are assigned with an = sign e.g. alias foo=bar

  2. quotes can't be nested like that; in this case, you can use single quotes around the alias and double quotes inside

  3. the backslash \ is a line continuation character: syntactically, it makes your command into a single line (the opposite of what you want)

So

#!/bin/bash

alias jo='
echo "please enter values "
read a 
read -e b 
echo "My values are $a and $b"'

Testing: first we source the file:

$ . ./myscript.sh

then

$ jo
please enter values 
foo bar
baz
My values are foo bar and baz

If you want to use the alias within a script, then remember that aliases are only enabled by default in interactive shells: to enable them inside a script you will need to add

shopt -s expand_aliases

Regardless of everything above, you should consider using a shell function rather than an alias for things like this


Get used to using functions in the POSIX-type shell. You don't have any of the quoting issues:

jo () {
    read -p "Enter value for 'a': " -e a 
    read -p "Enter value for 'b': " -e b 
    echo "My values are $a and $b"
}