Grep command

Hello,

I have a file which looks like this

C       Pos           Ref     BestGen BestQual  A+-     B+-     SP      CV
6       108858301       T       TT      ?2      +-      +-      TT      TT
6       108858304       C       CC      ?2      +       +       CC      CC
6       108858309       C       CC      ?3      +       +       CC      CC
6       108858312       C       CC      ?1      +       +       CC      CC
6       108858313       T       TT              +       +       TT      TT
6       108858315       T       TT      ?2      +       +       TT      TT
6       108858316       C       CC      ?2      +-      +-      CC      CC
6       108858317       T       TT      ?6      +       +       TT      TT
6       108858318       T       TT      ?2      +-      +-      TT      TT
6       108858321       T       TT      ?4      +-      +-      TT      TT
6       108858322       C       CC      ?8      +       +       CC      CC
6       108858325       T       TT              +-      +-      TT      TT
6       108858326       T       TT              +       +       TT      TT
6       108858328       A       AA      ?5      +       +       AA      AA
6       108858330       T       TT      ?6      +-      +-      TT      TT

I need to remove from the file all the lines which contain "?2" to "?8"

I tried using

grep -v '?2' '?3' '?4' '?5''?6' '?7' '?8'  filename > output

but I get an error

grep: ?3: No such file or directory
grep: ?4: No such file or directory
grep: ?5?6: No such file or directory
grep: ?7: No such file or directory
grep: ?8: No such file or directory

Any help is appreciated. Thank you

try this:

grep -v '\?[0-9]' filename

If this is not what you wanted, post the output as well.

The output should be something like this

C       Pos           Ref     BestGen BestQual  A+-     B+-     SP      CV
6       108858312       C       CC      ?1      +       +       CC      CC
6       108858313       T       TT              +       +       TT      TT
6       108858325       T       TT              +-      +-      TT      TT
6       108858326       T       TT              +       +       TT      TT

So basically I need all the information which have a blank value AND "?1" in that particular column..

Like this:

awk ' $5 !~ /?[2-9]/{print $0}' filename
1 Like

With grep and extended REs:

grep -Ev '\?(2|3|4|5|6|7|8)'  file
C       Pos           Ref     BestGen BestQual  A+-     B+-     SP      CV
6       108858312       C       CC      ?1      +       +       CC      CC
6       108858313       T       TT              +       +       TT      TT
6       108858325       T       TT              +-      +-      TT      TT
6       108858326       T       TT              +       +       TT      TT

And, small corrections/improvement to greet_sed's proposal:

awk ' $5 !~ /\?[2-8]/' file

Hi,
Here regular expression for grep command that check 5th field:

grep -Ev '^([^ ]+ +){4}\?[2-8]' file

Regards.

@greet_sed
You do not need the print command, its default.

awk '$5!~/?[2-9]/' filename