Not possible in just grep I believe I'll take a stab at the bonus though: echo "$name.jpg"