INPUT1="FOO1" INPUT2="FOO2"; RESULT=`perl -E 'for ( @ARGV) { s/FOO/BAR/; say ;}' $INPUT1 $INPUT2` #### $ echo $RESULT BAR1 BAR2