|
CS469/569 - Linux and Unix Administration and Networking
Spring 2022
|
Displaying ./code/h5/f.sh
#!/bin/bash
# (2 points)
# Make a random password generator: read 3 to 5 random lines from
# /usr/dict/words and assemble them together to form a random password.
# It should also take an optional minimum size argument that insures the
# password generated is of a minimum length. Additional the first letter of each
# word is should be capitalized.
# You may not use the shuf command for this assignment, use sed with the -n
# option and the p command (sed -n ##p /usr/dict/words)
# Assign a variable with a random value between 3 and 5:
# Find the number of lines in /usr/dict/words and store that in a variable
# Initialize a variable to be the value of the first command line parameter
# or 1 by default (the minimum length)
# Initialize a variable to be an empty string:
# Loop from 0 to the number of words you've picked and until the minimum length
# is reached:
# Use RANDOM to pick a random line # into /usr/dict/words
# Use sed to get the word at that line number in /usr/dict/words
# append the word (capitalizing the first letter) to the empty string you
# defined outside of the loop
# Print the generated password:
|