LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-06-2003, 07:27 AM   #1
gummimann
Member
 
Registered: Nov 2003
Distribution: redhat
Posts: 57

Rep: Reputation: 15
Question how to grep only one string pr match


Hi

How can get all different strings in a file from a file with many equal strings?

example: <command> <option> <search-string> fromfile.txt > newfile.txt

-Henki
 
Old 11-06-2003, 07:35 AM   #2
hanzerik
Member
 
Registered: Jan 2002
Location: Cheyenne Wyoming
Distribution: Debian/Raspbian/Mint
Posts: 717

Rep: Reputation: 32
cat <file> | grep 'word1 word2 word3' > file.txt

Put the words in single quotes ' '

That should work.
 
Old 11-06-2003, 07:44 AM   #3
gummimann
Member
 
Registered: Nov 2003
Distribution: redhat
Posts: 57

Original Poster
Rep: Reputation: 15
I wan`t the them only printed once. So I get just different matches in the file. none equal. So I can se how many different strings there are, cause there are many equal
 
Old 11-06-2003, 09:40 AM   #4
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Using the example you already were given:

cat <file> | grep 'word1 word2 word3' > file.txt
sort -um file.txt -o file1.txt

file1.txt now has duplicates removed.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
use grep and execute a command if string is found plisken Linux - General 6 07-28-2005 11:06 AM
Regular expression to match a valid URL string vharishankar Programming 13 07-21-2005 09:17 PM
grep [A-Z] & [a-z] match both upper and lower case. jschiwal Linux - General 4 05-28-2005 06:43 AM
iptables string match kahpeetan Linux - Security 3 11-09-2003 06:36 PM
grep - finding string and replacing with new ckibler Linux - Newbie 6 08-01-2003 06:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:48 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
Open Source Consulting | Domain Registration