How can I give space " " as input in shell script ?
Ex :
echo " Enter date for grep... Ex: Oct 6 [***Double space is important for single date***] (or) Oct 12 "
read mdate
echo $mdate
I get the output as Oct 6 but I want Oct 6.
You already have Oct 6 in $mdate, your problem is that you're expanding it when printing. Always use double quotes around variable substitutions. Additionally, to retain leading and trailing whitespace (those are stripped by read), set IFS to the empty string.
IFS= read -r mdate
echo "$mdate"
The -r (raw) option to read tells it not to treat backslashes specially, which is what you want most of the time (but it's not the problem here).
read toto ; echo "$toto" : when i enter ______this____ (_ are spaces) it outputs this (I believe this is not something done by read, but by the shell's line policy? how to change it? stty raw before the read, or something?)
IFS=. This is about the shell, it has nothing to do with terminal settings.
OLDIFS="$IFS" ; IFS="" read toto ; echo "__${toto}__" ; IFS="${OLDIFS}"
IFS for the duration of the read call.