export INP2="A String of Text" RES=$(perl -e '($x=$ENV{INP2})=~s/String/Wall/;print $x') echo $RES A Wall of Text