#!/bin/bash
PS3="input number"
select f in *
do
echo "the number is $REPLY,the file_name is $f"
done
exit 0
这个程序里PS3="input number" 此句什么意思?
为什么会先执行select f in *然后再是其他的?
#!/bin/bash
PS3="input number"
select f in *
do
echo "the number is $REPLY,the file_name is $f"
done
exit 0
这个程序里PS3="input number" 此句什么意思?
为什么会先执行select f in *然后再是其他的?
PS3是select语句的shell界面提示符,默认的提示符“#?”
select 表达式是一种bash的扩展应用,动作包括:
(1)、自动用数字列出菜单,(没有echo指令,自动显示菜单)*表示列出当前文件夹下的所有文件
(2)、自动read输入选择 (没有 read指令,自动输入)
(3)、赋值给变量 (没有赋值指令,自动输入数字后,赋值字符串给变量)