Caution: This is just a simple hack, and should only be considered as safe as saving passwords on the filesystem in any other circumstances.
I often end up saving non-vital passwords in ~/passlist, (never anything which I would mind losing), but I hate having to look them up. I save them in a format <passname>: <password>. This is great, but browsing, or even grepping this is annoying. The solution? Use bash and regex.
First, I just rigged up a simple grep script:
#!/bin/bash
#pwlst.sh - Grep's ~/passlist for the
# only passed argument
grep "$1" ~/passlist
This works, but leaves the entering the password to me, for example with ssh -l. Because I'm a bit lazy, I added some more processing to it - run it through sed, and cut everything but the password. This is done with a simple
sed "s/$1: //", to give us a script which we can easily pipe output from to a login, for example pwlst.sh <name> | ssh -l.
#!/bin/bash
#pwlst.sh - Grep's ~/passlist for the only
# passed argument, then cuts out the name.
grep "$1" ~/passlist | sed "s/$1: //"
As you can see, chaining grep to sed can do the work of many other commands - learning regex can even replace many other commands.
See also: