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?
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.