in reply to Re^3: Extracting password from array
in thread Extracting password from array

Untested

egrep "^$1:[^:]*:$2:" | cut -d':' -f2

Replies are listed 'Best First'.
Re^5: Extracting password from array
by ikegami (Patriarch) on Mar 26, 2010 at 19:03 UTC
    You hadn't specified the arguments were regex patterns, not text.
    perl -le'while(<STDIN>) { print $1 if /^$ARGV[0]:([^:]*):$ARGV[1]:/ }'
    If they are actually text, then you can easily solve that for the Perl version.
    perl -le'while(<STDIN>) { print $1 if /^\Q$ARGV[0]\E:([^:]*):\Q$ARGV[1 +]\E:/ }'

    Using split is bit longer, but more readable.

Re^5: Extracting password from array
by Anonymous Monk on Mar 26, 2010 at 18:47 UTC
    I forgot to include the file name, but I think you get the idea.