Skip to content
Advertisement

exit from STDIN from bash script when the user want to close it

I’m automating the file creation from a bash script. I generated a file rc_notes.txt which has commit messages from two tags and want to re-write that in a new file as rc_device.txt.

I want the user to write the customer release notes and exit from the BASH STDIN that I prompt in the terminal.

The problem in my script is I’m not able to trap the close of file.

Wondering how to do. I don’t want to trap the close signal. I want to enter magic string example: Done or some string that triggers the closure of STDIN, that exit from the script gracefully.


My script:

JavaScript

It does create the file but I need to exit manually by entering ctrl+D or ctrl+z. I don’t want to do that. Any suggestions?

Advertisement

Answer

To break the loop when “Done” is entered

JavaScript

or

JavaScript
Advertisement