-I made a bash function like this:
find_stuff () {
list=`find $SEARCHPATH -type f -user $USERID -mmin -$SOMETIME -not -path '*/\.*' -exec ls -1rt {} \+`
if [ -n "$list" ]; then
for i in $list; do
echo "Found item: "$i""; printf 'Is this ok? y/n [y]:'
read arg
case "arg" in
y|\Y)
do_stuff
;;
n|\N)
continue
;;
*)
echo "Please type 'y'=yes or 'n'=no, -exiting..."
exit 0
;;
esac
done
else
echo "No items found, exiting..."
exit 0
fi
}
Now I want to expand the function for the enduser like this:
./finditems.sh
Trying to find stuff and then do some stuff after confirmation.
Found item: /dir/mod.item
Is this ok? y/n [y]:y
How can I print the "user removable" y character on the user's shell prompt?
I tried some variations with read -p
, but it didn't give me the result that I want.
This implementation seems to complex. I have found another solution: By adding double quotes to y|\Y|"") I have eliminated the need for a 'y' character and questionable or unnecessary code. By pressing 'return' after the "Is this ok? y/n [y]:" statement the for-loop continues as expected.