linux - -s 和 -p 如何更改读取命令?
问题描述
我正在尝试解释这段代码。搜索谷歌以查看这些命令的含义,但没有运气。我解释了每行/块对我的意义。如果我错了,请纠正我。我是 unix 命令的新手。代码:
#!/bin/bash
# input 1st command line argument for the version.
export VERSION=$1
# if user didn't input a version, print the echo message and exit (not sure what -n means but I am assuming)
if [[ ! -n "$VERSION" ]]; then
echo "Missing Version"
exit 1
fi
# creating variable UNAME that tells who the person is (their name)
export UNAME='whoami'
# no idea what -s and -p mean but i think this prints the message "enter password for $UNAME" and stores it in a new variable named PASSWORD. the $UNAME will print whatever whoami said.
read -s -p "Enter password for $UNAME: " PASSWORD
echo ""
解决方案
-p
在尝试读取之前提示输出不带尾随换行符的字符串 PROMPT。
-s
不要回显来自终端的输入。
推荐阅读
- sql - 如何计算表中的对象数,按has_many中的列分组,某些条件很重要?
- ubuntu-18.04 - 如何在 ubuntu 中为 pgadmin4 设置深色主题
- java - 高级json字符串到java对象的处理和转换
- java - 有没有办法在测试中选择性地禁用对实体修改的审计?
- python - 如何以特定顺序依次运行包含测试套件的不同脚本文件
- hibernate-search - 从独立索引中删除,不会反映将已删除实体用作@IndexedEmbedded 的索引
- junit - 如何使用 Junit 测试套件仅重新运行失败的测试用例
- javascript - 如何从网页中获取文件目录
- amazon-web-services - 发电机数据库上的分区键
- php - 解码 Cookies 值并将数据保存在数据库中