Advertisement
tolikpunkoff

BASH: get random char from pattern string

Feb 6th, 2023
2,513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.15 KB | None | 0 0
  1. getrandchar() #$1 - pattern_string
  2. {
  3.     STRLEN=`expr length "$1"`
  4.     RNUM=`shuf -i 1-$STRLEN -n1`
  5.     RCHAR=`echo -e -n "$1"|cut -c$RNUM-$RNUM`
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement