设计师网站国外,江西锐安建设工程有限公司网站,软件开发流程pdf,办公室设计装文章目录 yes命令功能doc文档英文中文翻译完整文档 示例应用案例自动为脚本多次确认y yes命令功能
yes命令可以不断地输出换行的指定字符串#xff0c;不加参数时#xff0c;不断输出换行的“y”#xff0c;有时我们需要执行一些需要用户键入“y”确认的脚本#xff0c;但… 文章目录 yes命令功能doc文档英文中文翻译完整文档 示例应用案例自动为脚本多次确认y yes命令功能
yes命令可以不断地输出换行的指定字符串不加参数时不断输出换行的“y”有时我们需要执行一些需要用户键入“y”确认的脚本但是我们希望执行时能自动确认这时yes命令就能帮上我们的忙。
doc文档
yes --help英文
Usage: yes [STRING]...or: yes OPTION
Repeatedly output a line with all specified STRING(s), or y.--help display this help and exit--version output version information and exitGNU coreutils online help: https://www.gnu.org/software/coreutils/
Full documentation at: https://www.gnu.org/software/coreutils/yes
or available locally via: info (coreutils) yes invocation中文翻译
用法yes [字符串]...或者yes 选项
不断重复输出一行包含所有指定的字符串或者输出 y。--help 显示此帮助信息并退出--version 输出版本信息并退出GNU coreutils 在线帮助https://www.gnu.org/software/coreutils/
完整文档请参考https://www.gnu.org/software/coreutils/yes
或者在本地通过 info (coreutils) yes invocation 查看。完整文档
https://www.gnu.org/software/coreutils/yes 15.3 yes: Print a string until interrupted yes prints the command line arguments, separated by spaces and followed by a newline, forever until it is killed. If no arguments are given, it prints ‘y’ followed by a newline forever until killed. Upon a write error, yes exits with status ‘1’. The only options are a lone --help or --version. To output an argument that begins with ‘-’, precede it with --, e.g., ‘yes – --help’. See Common options.
yes打印字符串直到被中断 yes 打印命令行参数用空格分隔并在末尾加上换行符一直打印直到被终止。如果没有给出参数则一直打印 ‘y’并在末尾加上换行符直到被终止。 在写入错误时yes 以状态码 ‘1’ 退出。 唯一的选项是单独的 --help 或 --version。要输出以 ‘-’ 开头的参数请在其前面加上 --例如‘yes – --help’。请参阅常见选项。
示例
执行yes y后打印出了一连串不断换行的”y“ 执行yes hello打印出了一连串的换行“hello” 以空格分隔不断重复打印任意组合的换行字符串如yes hello world ! 应用案例
自动为脚本多次确认y
比如我有一个脚本执行时可能会让用户确认“y”代码片段和展示效果如下 用户可能需要多次键入“y”才能执行完脚本如果用户一个字母也不想敲可以这样
yes | ./your_script.sh或者
yes y | ./your_script.sh或者yes y | ./your_script.sh注意单个参数时参数加不加引号都一样但是如果脚本有时解析多个参数脚本逻辑不同可能导致最终结果不同
这将生成连续的y输入并将其作为输入传递给脚本。
我执行
yes | ./install_arm_ubuntu.sh可以看到我的脚本完全不用确认就咔咔一直往下走直到结束了