Get the input from user and save it as .txt file

Hi friends,

I am pretty new to shell scripting, please help me in this Scenario.

for example, If I have one file called input.txt

once I run the script,

1.It has to delete the old input.txt and create the new input.txt (if old input.txt is not there, no offence, just it has to create a new one)

  1. User has to paste the IDs (multiple line IDs) in the input.txt as a input.

  2. once User Enter the input, it has to save the input.txt.

please help me in that. Thanks in advance. SDorry for my English

  • Just overwrite the old file with a redirection like echo "" > input.txt
  • Read input with a prompt can be achieved with read . Else could use positional shell parameters of the shell like $1, $2, ...
  • For writing input.txt, redirect as said.

Try it, show your efforts. Ask if you get stuck showing your code.
According to your code in post Function is calling only once you should be able to get a start going.

cat > file

Then paste the ID's and press ctrl-d when finished,