Using awk, print all the lines where field 8 is equal to x

Using awk, print all the lines where field 8 is equal to x

I really did try, but this awk thing is really hard to figure out.

file1.txt

"Georgia","Atlanta","2011-11-02","x","","","",""
"California","Los Angeles","2011-11-03","x","","","",""
"Georgia","Atlanta","2011-11-04","x","x","x","x","x"
"Georgia","Atlanta","2011-11-05","x","x","","",""
"Georgia","Atlanta","2011-11-06","x","","","",""
"Rhode Island","Providence","2011-11-07","x","","","","x"

***OUTPUT***
result1.txt

"Georgia","Atlanta","2011-11-04","x","x","x","x","x"
"Rhode Island","Providence","2011-11-07","x","","","","x"

I tried all the following with different combinations. They either printed everything or nothing. None of the following is achieving the results. What am I missing here?

awk '{$8 == "x"} {print}' file1.txt
awk -F',' '($8 == "x") {print}' file1.txt
awk '$8 == "x"' file1.txt
awk '($8 == "x")' file1.txt
awk '{$8 == "x"}' file1.txt > result1.txt
awk -F',' '($8 == "x") {print $0}' file1.txt
awk '$8 = "x"' file1.txt
awk '$8 = /x/' file1.txt
awk -F'/",/"' '{$8 == "x"}' file1.txt
awk -F'",/"' '{$8 == "x"}' file1.txt
awk -F'",/"' '{$8 == "x"}' file1.txt

Also would be great to do field 6.

Thank You.

You are so close:

awk -F , ' $8 == "\"x\"" {print;}' input-file

If you want to capture lines where either is an x:

awk -F , ' $8 == "\"x\"" || $6 == "\"x\"" { print; }'

OMG, This is like a live chat; fast reponse. Less than 5 minutes.

Wow, I was beating myself up. Your the best.

Works!

And thanks for the || operator, and how to apply it. I will use this knowledge.

Thanks A Bunch

One more thing........

Just wanted to confirm, the opposite, which is to print only lines which don't contain x.

awk -F , '!($8 == "\"x\"") {print;}'

It works, but just want to get confirmation if this is the correct way of doing it. Is this correct?