-   Linux - Newbie (
-   -   Grep words made up of a single dot (

Fiatuno 05-02-2015 06:17 PM

Grep words made up of a single dot

grep "\." gives me

So does grep -w "\."

I need only

Thanks in advance

Keith Hedger 05-02-2015 06:30 PM

It would be nicje to see a sample of the file(s) you are trying to grep, moere info please, your grep command os ok it is matching a single . ... .. . ALL contain single dots you need to add some info around the dot to make it more specific hence we need to know what you are using as source data, try '\b\.\b' this is a single dot bounded by normal word boundary's. space tab newline etc

Fiatuno 05-02-2015 06:56 PM

Thank you Keith,

This is an extract of my file. It's an index.
'\b\.\b' didn't work

. 480
. 481
. 482
. 483
. 484
... 212

Keith Hedger 05-02-2015 07:01 PM

try '^\. '
^ anchors to the start of the linr then a asingle dot then a space, you may have to use -e before tge regex to grep.
or try sed -n '/^\. /pg' /path/to/your/file, whichwill print all lines that start '. '

Fiatuno 05-03-2015 03:48 AM

Hi Keith,

'^\. ' worked, I didn't have to use -e.:)

Thank you very much!

All times are GMT -5. The time now is 12:12 AM.