I have a file called ~failures.txt that contains both Production and Non Production backup failures, one line per server. I'd like to parse this file and put the Production failures in one file, and the Non-Production failures in another file.
The best way I can come up with is to cat the file one time for each search against the second field in the line.
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^PROD/' > $WORKINGDIR/~prodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^NON_PROD/' > $WORKINGDIR/~nonprodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^THIRD_POL/' >> $WORKINGDIR/~prodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^FOURTH_POL/' >> $WORKINGDIR/~prodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^ARMSSW/' >> $WORKINGDIR/~prodfailures.txt
Is there a more efficient/elegant way to do this?
Thanks, in advance!
630111
The best way I can come up with is to cat the file one time for each search against the second field in the line.
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^PROD/' > $WORKINGDIR/~prodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^NON_PROD/' > $WORKINGDIR/~nonprodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^THIRD_POL/' >> $WORKINGDIR/~prodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^FOURTH_POL/' >> $WORKINGDIR/~prodfailures.txt
# cat $WORKINGDIR/~failures.txt | awk '$2 ~ /^ARMSSW/' >> $WORKINGDIR/~prodfailures.txt
Is there a more efficient/elegant way to do this?
Thanks, in advance!
630111