LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-18-2012, 12:20 AM   #1
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Rep: Reputation: Disabled
Smile need help to avoid duplication while using grep


hi all,

I would like to grep without duplication, what should I do,

say

I have file abc.txt

contains
n xyz jik
n xyz jik

I have another file def.txt

what command I should use in script to copy n xyz jik once from abc.txt to def.txt

right now I am using

grep -i "xyz" $abc >>$def

but it causes duplication

and thus the output is
n xyz jik
n xyz jik

I want it to be

n xyz jik

looking forward for the reply

Thank you in advance
 
Old 04-18-2012, 12:28 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

With greps -m <num> option you can limit the amount of hits.

The following should limit the found string to one:
Code:
grep -m 1-i "xyz" $abc >>$def
Hope this helps.
 
1 members found this post helpful.
Old 04-18-2012, 12:31 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Code:
grep xyz abc.txt | uniq>def.t
http://linux.die.net/man/1/uniq
 
1 members found this post helpful.
Old 04-18-2012, 12:38 AM   #4
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Original Poster
Rep: Reputation: Disabled
Smile

Thank you chrism.....its working....
 
Old 04-18-2012, 02:47 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome

BTW: Can you put up the [SOLVED] tag.
first post -> Thread Tools -> Mark this thread as solved
 
Old 04-18-2012, 03:31 AM   #6
bal_nair1
Member
 
Registered: Apr 2012
Location: Bangalore,India
Posts: 41

Original Poster
Rep: Reputation: Disabled
Unhappy How to access information form popups?

There is one FEA software known as Medina, which popups a message box in its GUI in its operation.I would like to access the information from the message box.For more clarity please see the image attached with this post.
I am suspecting whether any log file being wriiten in some directory corresponds to the message box.
Attached Thumbnails
Click image for larger version

Name:	Tsystm.png
Views:	9
Size:	117.0 KB
ID:	9470  
 
Old 04-18-2012, 03:40 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
@bal_nair1: This new question (post #6) isn't at all related to the original question you asked in this thread.

You might want to ask a moderator (use the report button) to split post #6 from the rest and make it a new thread. This way it gets the attention it deserves.
 
1 members found this post helpful.
Old 04-18-2012, 07:04 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
@druuna: trying to steal my applause eh
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoid .svn folder when using grep jostmart Linux - General 2 06-02-2007 12:27 AM
Disk Duplication jcombrink Linux - Enterprise 3 03-27-2007 02:29 AM
Packet duplication!!! vishamr2000 Linux - Networking 1 04-25-2006 04:37 PM
C source code duplication slzckboy Programming 6 07-30-2005 06:04 PM
HDD Duplication... PenguinPwrdBox Linux - General 3 12-16-2004 04:25 PM

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

All times are GMT -5. The time now is 08:31 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