-s和-p如何更改读取命令? [英] How do -s and -p alter the read command?

查看:67
本文介绍了-s和-p如何更改读取命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解释此代码块.搜索谷歌,看看这些命令的意思,没有运气.我对每行/每行对我的含义进行了解释.如果我错了,请纠正我.我是unix命令的新手.代码:

I'm trying to interpret this block of code. Searched google to see what these commands mean and no luck. I put my interpretation of what each line/block means to me. If I am wrong, please correct me. I am new to unix commands. Code:

#!/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标志在将输入读入变量之前会发出提示

The -p flag issues a prompt before reading input into a variable

-s标志停止显示键入的响应(即,用于敏感密码)

The -s flag stop the typed response from being shown (i.e. for a sensitive password)

可在此处获得更多信息:

More information is available here:

https://linuxhint.com/bash_read_command/

这篇关于-s和-p如何更改读取命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆