Doubt regarding stderr

Hi All,
I am writing a shell script code. and i want the stderr to be send to a file and the stdout to be displayed in terminal. In my shell script code i use a read command to get data from user.

read -r -p "Enter the type :" data

and while i execute my script i use

./my_script.sh 2> filename

My doubt is why Enter the type: which I use with read command is not displayed in terminal, but in STDERR instead (filename) ??

Any insight will be helpful to me:D

Welcome to the forum.

That's a feature of your shell, e.g. man bash :

Thanks @RudiC for your answers,

But even if i remove -p option from read command, same output as previous is observed.

Which is difficult to believe.

Please

  • tell your OS and shell versions
  • show your command
  • post the contents of filename

i got it now....Thanks