Not sure why this got downmodded to oblivion, but anyway.
grep "[a-zA-Z]"
grep is a search tool, using regular expressions. This specific expression looks for a character range (in brackets) of lowercase (a-z) or uppercase (A-Z). So, it will match a single ASCII letter on input.
NOTE Since this line does not say a file (or a pipe) to read from, it will read from stdin until you end it with a Ctrl-D. Meaning your terminal will appear to hang, even though it's searching.
sort -u
Sort stdin (see note above) then coalesce lines that are next to each other into a single line, meaning list only unique lines
awk -F"," '{if($4 == "2" && $6 == "UPD-LOC" && $7 == "OUT"){
print $11,$12,$18,$23,$11$12
}}' $txnfile_fail | sort | tr ' ' ',' >$TEMP_FOLDER/txnFailOut-$1.txt
awk is a useful tool for manipulating text files, somewhere between bash+grep and perl in complexity and headaches. This is using awk's power to read columns,
Run the awk tool on the file named in the variable $txnfile_fail. The -F flag is for field delimiter, so its a comma delimited input file. Check if the 4th field is a 2, if the 6th field is 'UPD-LOC', and the 7th field is 'OUT'. If so, dump out fields 11, 12, 18, 11, 12. Then sort the output, translate spaces to commas, and then dump to the file $TEMP_FOLDER/txnFailOut-$1.txt.
So, it filters a csv file, prints only certain columns, sorts the filtered input and dump to a different file. Oddly its fine with spaces as output separators, then translates the spaces to different characters. You can set the separator in awk with the 'OFS=,' awk statement.