LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 01: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, 01:28 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
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, 01:31 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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, 01: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, 03:47 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
You're welcome

BTW: Can you put up the [SOLVED] tag.
first post -> Thread Tools -> Mark this thread as solved
 
Old 04-18-2012, 04: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:	4
Size:	117.0 KB
ID:	9470  
 
Old 04-18-2012, 04:40 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
@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, 08:04 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

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


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
Avoid .svn folder when using grep jostmart Linux - General 2 06-02-2007 01:27 AM
Disk Duplication jcombrink Linux - Enterprise 3 03-27-2007 03:29 AM
Packet duplication!!! vishamr2000 Linux - Networking 1 04-25-2006 05:37 PM
C source code duplication slzckboy Programming 6 07-30-2005 07:04 PM
HDD Duplication... PenguinPwrdBox Linux - General 3 12-16-2004 05:25 PM

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

All times are GMT -5. The time now is 06:23 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration