Don’t Script Your Password! Add Simple Prompts to Shell Scripts

I hate typing long shell commands, so I often create for myself short shell scripts that perform common tasks for me. I can hard-code all those options and arguments. Sometimes, though, there are a few bits that I want to change on a run or I don’t want to hard code into a shell script.

Here’s an excellent example: I don’t want my password stored in a shell script. Ideally, what I want is to be prompted for my password.

There is a very simple shell built-in that you can use to do this: read. Here’s how it’s used.