1

Bash script - String compare does not seem to work

view story
linux-howto

http://stackoverflow.com – I have an input file with contents in the following format: ABCD XYZAB 1234 PQRSTUV STU SKIP LMN OPRQM 8966 RSTUV OPM SKIP TUV ZXU SKIP I want to parse this file and output it to a new file such that, rows with their last column as "SKIP" do not appear in the final output file, as below: ABCD XYZAB 1234 LMN OPRQM 8966 To process the above, I wrote up the following shell script: while read -r col1 col2 col3 do if [ "$col3" != "SKIP" ] then printf "%s %s %s\n" "$col1" "$col2" "$col3"; fi done <input.txt > output.txt Bu (HowTos)