Matching a decimal number?

Hi everyone!

Easy question for everyone. I'm trying to run a command line to find an exact match of a decimal number within a file. The number can be a positive OR negative number. For instance, if I want to find only the number -1 in the file that has:

-17.6
-17
-16.3
-16.2
-15.7
-15.3
-15.2
-1
-14.7
-14.3
-11
-10.9
-10.1
-10
-9.1
-8.1

how can I do this?
I tried cat myfile.asc | sed -n '/-1/ p' but this doesn't seem to work :frowning:

Thanks!!

hi,

egrep '^-1$' myfile.asc

or

grep -w -- '-1' myfiles.asc
grep '^-1$' filename

that's great! However, is there any way to do this using awk/gawk instead?

Thanks

Fixed string, whole line matching:

grep -Fxe -1

Regards,
Alister

Hi
With awk

awk '/^-1$/ { print; }'

this is perfect! Thanks guys!!