LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grep words made up of a single dot (https://www.linuxquestions.org/questions/linux-newbie-8/grep-words-made-up-of-a-single-dot-4175541439/)

Fiatuno 05-02-2015 05:17 PM

Grep words made up of a single dot
 
Hi,

grep "\." gives me
...
..
.

So does grep -w "\."

I need only
.

Thanks in advance

Keith Hedger 05-02-2015 05: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 05: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 06: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 02: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 05:52 AM.