LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 07-04-2007, 07:47 AM   #1
Coimbra
LQ Newbie
 
Registered: May 2007
Posts: 20

Rep: Reputation: 0
Select only words with a letter


Hi,

Can I select only words with the letter "a" for example? On a file txt.

example:

cat expre.txt | grep........

regards
 
Old 07-04-2007, 07:57 AM   #2
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
Grep will give you the entire line if it encounters a match.

Do you just want the specific word only that has an "a" in it?
 
Old 07-04-2007, 08:02 AM   #3
Coimbra
LQ Newbie
 
Registered: May 2007
Posts: 20

Original Poster
Rep: Reputation: 0
yeap,

I only want words with letters "a".

I know than the documentos only has words with letters "a" and "b".
 
Old 07-04-2007, 08:05 AM   #4
Coimbra
LQ Newbie
 
Registered: May 2007
Posts: 20

Original Poster
Rep: Reputation: 0
The document is similar to:

aaa
abbabba
aaaabba
aba
aab
bba
baab
..
..
..
..
 
Old 07-04-2007, 08:28 AM   #5
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Umm if you mean there are only words that consist of either a, b or both of them, and you want to print lines with only 'a's (which means: you don't want to print lines that have 'b's in them)? In that case:

Code:
grep -v b file.txt
Actually I'm not sure if "b" or "file.txt" comes first; I always forget it. Well, try and see

EDIT: the above works if there's one word per one line. If there are multiple, it will not work.
 
Old 07-04-2007, 08:39 AM   #6
Coimbra
LQ Newbie
 
Registered: May 2007
Posts: 20

Original Poster
Rep: Reputation: 0
PERFECT!!!!!!!!!!!


I have to use the next command:

cat [name_fichero] | grep -v b

It's perfect
 
Old 07-04-2007, 09:45 AM   #7
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by Coimbra
PERFECT!!!!!!!!!!!


I have to use the next command:

cat [name_fichero] | grep -v b

It's perfect
Code:
grep -v b name_fichero
 
  


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
Script to move directories based on first letter to a new directory of that letter tworkemon Linux - Newbie 8 01-30-2007 08:18 PM
Select() did not select my socket thvo Programming 1 05-08-2005 01:20 AM
Words you've never used acid_kewpie General 26 12-23-2004 04:21 AM
Search and Replace: Asian Words to English Words ieeestd802 Linux - Software 0 10-27-2004 08:48 PM
Mandy 9.2- Passwords have become 5-6 letter words I can't change. Mitsurugi Mandriva 0 03-20-2004 11:31 AM


All times are GMT -5. The time now is 05:22 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration