rand-string.sh
来自「Shall高级编程」· Shell 代码 · 共 30 行
SH
30 行
#!/bin/bash# rand-string.sh# Generating an 8-character "random" string.if [ "-n $1" ] # If command line argument present,then #+ then set start-string to it. str0="$1"else # Else use PID of script as start-string. str0="$$"fiPOS=2 # Starting from position 2 in the string.LEN=8 # Extract eight characters.str1=$( echo "$str0" | md5sum | md5sum )# Doubly scramble: ^^^^^^ ^^^^^^randstring="${str1:$POS:$LEN}"# Can parameterize ^^^^ ^^^^echo "$randstring"exit $?# bozo$ ./rand-string.sh my-password# 1bdd88c4# No, this is is not recommended#+ as a method of generating hack-proof passwords.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?