perl -ne 'print $1,"\n" foreach /[name|id]="(\w+)/' myfile.txt #### perl -ne 'print "$1\n" if /[name|id]="(\w+)/' myfile.txt