-1

I have 6000 lines,with one per number float.

My code

awk '5.400000e+03 {print $0}' base.txt

Only prints numbers

5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03
5.400000e+03

I have changed to

awk '{if($0=="5.400000e+03 ") print NR}' base.txt

but then got nothing! What should I try?

Richard Rublev
  • 7,718
  • 16
  • 77
  • 121

2 Answers2

3

You can use:

awk '$1 == "5.400000e+03" {print NR, $0}' base.txt

$1 will always match first column irrespective of spaces or no spaces after shown data in your question. Use print NR, $0 to print each record prefixed with record number.

anubhava
  • 761,203
  • 64
  • 569
  • 643
3

You can also use grep:

# just the line number
grep -wn "5.400000e+03" base.txt | cut -d: -f1
# both
grep -wn "5.400000e+03" base.txt
dimid
  • 7,285
  • 1
  • 46
  • 85