When I execute following command, on bash shell I get error but on Korn shell it runs perfectly fine. The only difference is missing single quote at the end of awk, after }. Could you help me understand why?
echo `echo "a b c d" | awk '{ print $1 }`
In the Korn shell, both back ticks and quotes can be left unmatched, the tokenizer will try and guess where either will end and match them accordingly.
Examples:
/home/ufierro # echo "`echo ah"
+ echo ah
+ echo ah
ah
/home/ufierro # echo `echo 'hello world`
+ echo 'hello world'
+ echo hello world
hello world
Notice how both examples show a different case for the behavior mentioned above.
The first example shows how, a single back tick within double quotes was completed during parsing and the second example shows how a single quote inside back ticks was completed as well.