I'm looking to set up a bash script that generates passwords. My idea is to use two lists of words and randomly select one word from each list. I'd like to add a random special character at the end, followed by a random assortment of four numbers. Any suggestions on how to implement this?
3 Answers
You can definitely do that! In bash, you can define a list of special characters and use the `RANDOM` variable to pick random items. For example, you could combine two randomly selected words from a dictionary, a random special character, and a four-digit number like this:
```bash
rand_chars='!@#$%^&*()_+-=[]{}|;:,.';
num_chars=${#rand_chars};
ridx=$((RANDOM % num_chars));
printf "$(shuf -n 1 /usr/share/dict/words)$(shuf -n 1 /usr/share/dict/words)${rand_chars:$ridx:1}$(printf "%04d" $((RANDOM % 10000)))n"
```
This way, you'll have a nice mix! If you're looking for simplicity, consider using Python or Perl too, as they have libraries that make this even easier.
Just a heads up, while bash can work for this, if you’re comfortable with PowerShell, there are a lot of existing scripts out there that can do the same thing. Plus, if you really want to ensure your password security, focus on length — combining 4 or 5 words from a dictionary is often more effective than just a couple of words and a few numbers.
Also, check out this password generator resource: fortypoundhead.com/showcontent.asp?artid=24579. It has a specific section for generators that might give you some solid ideas!

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically