read -n1 -p "Do you want to continue [Y/N]:" case $REPLY in Y | y ) echo echo "fine,continue";; N | n ) echo echo "ok, bye";; esac echo "END of the script" image.png 14.6.3 隐藏方式读取 使用read -s命令可以避免输入的内容出现在显示器上,最典型的例子就是输入密码,如下图...
# getting just one character of input # read -n1 -p "Do you want to continue [Y/N]? " answer case $answer in Y | y) echo echo "fine, continue on…";; N | n) echo echo OK, goodbye exit;; esac echo "This is the end of the script" 本例中将-n选项和值1一起使用,告诉read...
用 read 指令,编写一个 script ,他可以让使用者输入:1. first name 与 2. last name, 最后并且在屏幕上显示:“Your full name is: ”的内容:[dmtsai@study bin]$ vim showname.sh #!/bin/bash # Program: # User inputs his first name and last name. Program shows his full name. # ...
read -p "Input passwd:" -s Passwd echo $Passwd c. 限时输入,否则退出 #延迟五秒,没有输入将自动退出 read -p "Input a number:" -t 5 Number d. 读取限定字符 #从输入中取5个字符 read -p "Input a word:" -n 5 Word e. 等待输出q退出 #输入,直到输入q,将自动退出 read -dp -p "Input...
通过在命令行中输入`./script.sh -a 5 -b 10`,即可将选项-a和-b后的整数作为输入赋值给变量num1和num2。 4. 使用管道: 可以使用管道符号和read命令结合来读取两个整数。以下是一个例子: “`shell echo “5 10” | { read num1 num2; echo “您输入的两个整数分别为: $num1 和 $num2”; } ...
#use what we learned in a script. #Let's get some information from the user and add it to our scripts with stanard input and read echo "What is your name? " read name #Here standard output directed to append a file to learnToScirptStandardOutput ...
perf利用Linux的trace特性,可以用于实时跟踪,统计event计数(perf stat);或者使用采样(perf record),报告(perf report|script|annotate)的使用方式进行诊断。 perf命令行接口并不能利用所有的Linux trace特性,有些trace需要通过ftrace接口得到。 参考https://github.com/brendangregg/perf-tools ...
# 打印一个环境安装的脚本menu(){cat<<END1.[install lamp]2.[install lnmp]3.[exit]please input the num you wantEND}# 执行打印菜单 menu # 读入一个执行的编号 read num["$num"="1"]&&{echo"start install lamp."# 检查安装的脚本是否有执行权限[-x/root/Desktop/workspace/shell/Demo01/script/...
[elvis@station elvis]$ head -5 /etc/rc.d/init.d/* ==> /etc/rc.d/init.d/acpid <== #!/bin/bash # # /etc/rc.d/init.d/acpid # # Starts the acpi daemon ==> /etc/rc.d/init.d/anacron <== #!/bin/sh # Startup script for anacron # # chkconfig: 2345 95 05 # ...
# testing input/output file descriptor exec 3<> testfile #<>是表示重定向输入,又可以重定向输出 read line <&3 #读取testfile,每行内容 echo "Read: $line" #打印内容,输出 echo "This is a test line" >&3 #写入,输入 $ cat testfile ...