1

I would like this command to print a dash if grep not found (in addition to the new line already coded):

while read vl ; do grep -w "$vl" APL_vs_HS.tab || printf "\n" ; done < 1

Thanks! Bernardo

anubhava
  • 761,203
  • 64
  • 569
  • 643
biotech
  • 697
  • 1
  • 7
  • 17
  • 1
    By "grep not found", do you mean that the `grep` command doesn't exist, or that `grep` doesn't find the pattern? I presume the latter, but the way you phrased it implies the former. – Keith Thompson Dec 19 '13 at 17:07

2 Answers2

5

Why do you need to use printf? Simply use echo, then you won't need to worry about printing a newline because echo automatically outputs one.

while read vl ; do grep -w "$vl" APL_vs_HS.tab || echo "-" ; done < 1
dogbane
  • 266,786
  • 75
  • 396
  • 414
4

See this, so that one would do

while read vl; do grep -w "$vl" APL_vs_HS.tab || printf -- "-\n" ; done < 1
Community
  • 1
  • 1
kbshimmyo
  • 578
  • 4
  • 13