#!/bin/bash function grepo { grep --color=always "$1" . -r | awk '{ count++; print " ["count"] "$0 } ' echo -n "Select number to open: " read num IFS=" " CHOICES=( `grep -n "$1" . -r | awk 'BEGIN{ FS=":" }{ print "notepad /g "$2" "$1 }'` ) bash -c ${CHOICES[$(( num - 1 ))]} }