Generate random text file in terminal
Set this environment variable and you should be good to go:
setenv LC_ALL C
The answer for which I found on this page.
And with that environment variable in place, I see a nicely formatted output:
tr -dc A-Za-z0-9 < /dev/urandom | head -c100Kk4kfjR3O0UraMpfTGicGvYCziFClJQUTO3zCXdo05RTxEUigqPXTkjtiGOsTsaNyqNR3rX2dsmPlHkSdqO5qWBTmIFIYezsekWT[~]:;
# Print or assign a random alphanumeric string of a given length.# rndstr len [ var ]function rndstr { if [[ $FUNCNAME == "${FUNCNAME[1]}" ]]; then unset -v a printf "$@" elif [[ $1 != +([[:digit:]]) ]]; then return 1 elif (( ! $1 )); then return else typeset -a a=({a..z} {A..Z} {0..9}) eval '${2:+"$FUNCNAME" -v} "${2:-printf}" -- %s "${a[RANDOM%'"${#a[@]}"']"{1..'"$1"'}"}"' fi}rndstr 100
This is my library function for this. The advantage is performance and the ability to assign to a variable directly. Might be overkill for you.