I had a similar question earlier but this time I need something a bit more sophisticated:

In a txt file that looks like this:

```
147 186741 2S74M -162
83 647172 1S75M -221
163 584665 74M2S 271
99 658416 5S65M6S -272
163 718735 60M16S 243

```

I want the awk to look at the 3rd column, when it encounters character "S" in either 2nd or 3rd position, it then looks at the first column, when it encounters either "147" or "83", it discards that line. The rest of the results are passed to the second awk where it looks at the 3rd line again, when it encounters character "S" at the end, it then looks at the 1st column and if it finds either "99" or "163" it discards those lines. Then it prints the rest of the lines that didn't meet these filters. 

I tried something along these lines, but got blank file:

```
awk -Ft '{if ($3 ~ /S$/  && $1 ~ /99|163/)} {next}' | awk -Ft '{if ($3 ~ /^..?S/ && $1 ~ /147|83/)} {next} $6 ~ /S/ {print}' input.txt > output.txt 

```