#!/path/to/your/perl # $1 $2 $3 (shell) are in $ARGV[0], $ARGV[1] and $ARGV[2] (perl) $ARGV[2]=~ s/[\r\n]+/ /g; # Now $3/$ARGV[2] doesn't contain any newline/linefeed anymore $shellindex=1; foreach (@ARGV) { print '$',$shellindex,' ($ARGV[',$shellindex-1,']: ',$_,"\n"; ++$shellindex; }