"tmp/${FILENAME}.lid" paste "tmp/${FILENAME}.lid" "tmp/${FILENAME}.txt" | \ awk '($2 > 0.8 || ($1=="__label__hr" && $2 > 0.4)) && length() > 100 {lang = substr($1, 10); $1=""; $2=""; print $0 >> "shard/"lang".txt"}' Here is the offending piece of code I have 20TB of plain text that I want to classify by language