LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-02-2015, 05:17 PM   #1
Fiatuno
LQ Newbie
 
Registered: May 2015
Posts: 3

Rep: Reputation: Disabled
Grep words made up of a single dot


Hi,

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

So does grep -w "\."

I need only
.

Thanks in advance
 
Old 05-02-2015, 05:30 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,148

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
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
 
Old 05-02-2015, 05:56 PM   #3
Fiatuno
LQ Newbie
 
Registered: May 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-02-2015, 06:01 PM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,148

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
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 '. '

Last edited by Keith Hedger; 05-02-2015 at 06:04 PM.
 
Old 05-03-2015, 02:48 AM   #5
Fiatuno
LQ Newbie
 
Registered: May 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hi Keith,

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

Thank you very much!

Last edited by Fiatuno; 05-03-2015 at 02:49 AM. Reason: SOLVED
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep for words with special characters dwezel Linux - General 5 07-07-2012 03:23 PM
Can I use grep to find two words near each other? walterbyrd Linux - Software 4 12-09-2011 11:01 PM
how to grep 2 words at the same time ufmale Linux - Newbie 2 09-09-2010 04:25 PM
grep multiple words any order (AND, not OR) single line, from many files cedardoc Linux - Newbie 7 07-29-2010 10:23 AM
Can grep filter out words? extrasolar Linux - General 1 07-20-2006 03:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration