Jump to content
Im trying to find a "cleaner" way of writing this (lab assignment): 
 
#!/bin/bash
 
if [ "$1" = "" ]; then
        pass() { echo ${1:RANDOM%${#1}:1} $RANDOM; }
{
        pass 'abcdefghijklmnopqrstuvwxyz'
        pass 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        pass '0123456789'
        pass '@#$%&*+-='
        for i in $( seq 1 $(( 4 + RANDOM % 8 )) )
    do
        pass '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%^&*+-='
    done
}| tee t | sort -R | awk '{printf "%s",$1}'
        echo " is a valid password"
        exit 0
fi
 
This is a program generator and it should validate or generate a password. 
  • must be at least 8 characters long but not longer than 16 characters.
  • must contain at least 1 digit (0-9).
  • must contain at least 1 lowercase letter.
  • must contain at least 1 uppercase letter.
  • must contain exactly one and only one of @ #  $  %  &  *  +  -  =

 

 

Link to comment
https://linustechtips.com/topic/323370-bash-scripting-help/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×