LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 06: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, 06:30 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,252

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
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, 06: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, 07:01 PM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,252

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
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 07:04 PM.
 
Old 05-03-2015, 03: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 03: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 04:23 PM
Can I use grep to find two words near each other? walterbyrd Linux - Software 4 12-10-2011 12:01 AM
how to grep 2 words at the same time ufmale Linux - Newbie 2 09-09-2010 05:25 PM
grep multiple words any order (AND, not OR) single line, from many files cedardoc Linux - Newbie 7 07-29-2010 11:23 AM
Can grep filter out words? extrasolar Linux - General 1 07-20-2006 04:14 PM


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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration