目前,我正在通过一系列练习来提高bash脚本知识。
我正在做的练习如下:编写一个名为encrypt.sh的脚本,用于加密文件。以下是脚本的要求:
我觉得我现在的脚本已经满足了1-5,7-8的要求。然而,我对第6和第9条感到有些困惑。
任何反馈意见,我目前的工作,或解决方案,我的缺失的需求,将不胜感激。
提前谢谢你。
usage="Usage: Enter the name of the file you would like to encrypt as a parameter, eg. $0 words"
ENCRYPTION_KEY="1234"
export ENCRYPTION_KEY
openssl enc -e -aes256 -in "$1" -out "$1".enc -pass env:ENCRYPTION_KEY
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo $usage
fi
if test -z ${1}
then
echo "${0} :ERROR: No parameters provided. Please see -h or --help for usage." 1>&2
exit 1
fi
#DECODE (script is not required to decode, just here for testing purposes)
#openssl enc -d -aes256 -in words.enc -out words.enc.dec -pass env:ENCRYPTION_KEY发布于 2018-10-09 01:40:13
对于#6,这个read巴什积木将会很有帮助。对于#9,确保变量名在所有使用它们的地方都是双引号。
https://unix.stackexchange.com/questions/474107
复制相似问题