#!/bin/bash # Copyright (C) 2005 Krzysztof Kozlowski # License: GNU General Public License version 2 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # version 2 as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Ostatnia zmiana: 20.03.2006 # # Generate random alfanumeric characters # # # # Function usage : # random_text length # random_text () { if [ "$1" == "" ]; then _length=6 else _length=$1 fi i=0 while [ $i -lt ${_length} ] do i=`expr $i + 1` abc="a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9" litery=($abc) count=${#litery[*]} echo -n ${litery[$((RANDOM%count))]} done echo } # Example : #random_text $1