【发布时间】:2015-02-03 14:17:56
【问题描述】:
-我做了一个这样的bash函数:
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
}
现在我想为最终用户扩展功能,例如 this:
./finditems.sh
试着找东西,确认后再做一些东西。
Found item: /dir/mod.item
Is this ok? y/n [y]:y
如何在用户的 shell 提示符上打印“用户可移动”y 字符?
我尝试了read -p 的一些变化,但它没有给我想要的结果。
【问题讨论】:
-
如果您正在尝试做我认为您可以使用
tput cub 1在打印y后将光标移回一个空格,以便光标位于y 上方?
标签: linux bash shell for-loop getopts