How can i get this feature to work?
Pressing Esc while taking inputs from the user will exit the script
read -r -p "Enter the filenames: " -a arr
if press Esc; then
read $round
mkdir $round
fi
for filenames in "${arr[@]}"; do
if [[ -e "${filenames} ]]; then
echo "${filenames} file exists (no override)"
else
cp -n ~/Documents/library/normal.cpp "${filenames}"
fi
done
How can i detect Esc key in this script?
PS: Saw many resources
https://www.linuxquestions.org/questions/linux-newbie-8/bash-esc-key-in-a-case-statement-759927/
they use another variable like $key
or read -n1 $key
just one character input
but here what will i do if I've a string or an array?
read
call and ask for confirmation to execute then evaluate the reply(yes/no) in anif
statement to either copy the files or do something else.