#!/bin/bash
tty=$(readlink /proc/$$/fd/2)
echo "Paste Content below"
readarray -d '\n' lines < $tty
printf '%s\n' "${lines[@]}" > links.txt
So i am using the above script to store a block of text in a variable lines and write it to a file links.txt . The thing is when the readarray prompt shows up and i paste my text , i have to stop the read process by doing ctrl + d , after that the script proceeds further and writes the stored variable to links.txt
Ideally i want some particular keyword to act as endpoint of my paste where the read prompt ends automatically as soon as that particular word is detected
For example , after i have pasted my content. if i enter stopread
on a new line it should stop the read process and proceed further with the script
( i have just used the word stopread as an example )
Example - In readarray prompt , if i paste
1
2
3
stopread
it should store 1 ..3 in variable lines and and proceed further in script without the need of doing ctrl + d to stop close read prompt