LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 06-22-2012, 02:17 PM   #1
Alok Behria
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Rep: Reputation: Disabled
print only unique values


Hi All,

I have a one text file , in which I have duplicates values , which is starting as ORA-
related. now , I need to print only values , which has uniq ora , irrespective of the entire line , whihc is uniq.

Quote:
<<File>>
ORA-01917: user or role 'DDOWNS' does not exist
ORA-01917: user or role 'DDUNTON' does not exist
ORA-01917: user or role 'DECAVET' does not exist
ORA-01917: user or role 'DEDGAR' does not exist
ORA-01917: user or role 'DEJOHNSO' does not exist
ORA-39082: Object type TRIGGER:"RDS"."INGREDIENT_LABEL_00_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PRODUCT_REGISTRATION_00_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PRODUCT_REGISTRATION_01_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PRODUCT_MSDS_01_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PRODUCT_MASS_CODE_00_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PRODUCT_MASS_CODE_01_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PROCESS_INGREDIENTS_01_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PLANT_SUPPLY_00_T" created with compilation warnings
ORA-39082: Object type TRIGGER:"RDS"."PLANT_SUPPLY_00_T" created with compilation warnings
ORA-39112: Dependent object type TRIGGER:"SQLNAV"."PROJECTLISTTRIGGER" skipped, base object type TABLE:"SQLNAV"."SQLNAV4_PROJECT_LIST" creation failed
ORA-39112: Dependent object type TRIGGER:"SQLNAV"."PROJECTTIMESTAMPTRIGGER" skipped, base object type TABLE:"SQLNAV"."SQLNAV4_PROJECT" creation failed
ORA-39112: Dependent object type TRIGGER:"SQLNAV"."USERMAPTIMESTAMP" skipped, base object type TABLE:"SQLNAV"."SQLNAV4_USER_MAPPING" creation failed
ORA-39112: Dependent object type TRIGGER:"SQLNAV"."TIMESTAMPTRIGGER" skipped, base object type TABLE:"SQLNAV"."SQLNAV_PROGRAM_STATUS_LOG" creation failed
--- should be print like following---

ORA-01917: user or role 'DDOWNS' does not exist
ORA-39082: Object type TRIGGER:"RDS"."INGREDIENT_LABEL_00_T" created with compilation warnings
ORA-39112: Dependent object type TRIGGER:"SQLNAV"."PROJECTLISTTRIGGER" skipped, base object type TABLE:"SQLNAV"."SQLNAV4_PROJECT_LIST" creation failed
 
Old 06-22-2012, 02:38 PM   #2
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 3,079
Blog Entries: 4

Rep: Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745
Sorry, uniq doesn't work that way. The entirety of each line is considered when using uniq.

I was wrong, Sorry.

Last edited by Habitual; 06-22-2012 at 03:48 PM.
 
Old 06-22-2012, 02:42 PM   #3
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,565

Rep: Reputation: 410Reputation: 410Reputation: 410Reputation: 410Reputation: 410
Code:
 sort ./test.txt | uniq -w9
Where test.txt is your filename.

---------- Post added 06-22-12 at 12:43 PM ----------

Habitual please stop posting info that is incorrect, twice today I caught you. The -w option can specify the number of characters to compare, in this case 9.
 
Old 06-22-2012, 03:43 PM   #4
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 3,079
Blog Entries: 4

Rep: Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745
Quote:
Originally Posted by Kustom42 View Post
[CODE]
Habitual please stop posting info that is incorrect, twice today I caught you. The -w option can specify the number of characters to compare, in this case 9.
There's a gazillion ways to do stuff in Linux and my replies are not the absolute answer to anything, hence "Someone else may have more to say about this."

Now I know that -wN will ONLY count the first N as "unique". Thanks for that.

Yeah, you "caught" me alright. Trying to help some people out.
 
Old 06-22-2012, 03:47 PM   #5
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,565

Rep: Reputation: 410Reputation: 410Reputation: 410Reputation: 410Reputation: 410
I'm not trying to flame you but I felt that if I didn't repost this guy would walk away thinking it's not possible and that's something we want to avoid. Thanks for trying to help out with community and welcome to LQ.
 
Old 06-22-2012, 03:49 PM   #6
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 3,079
Blog Entries: 4

Rep: Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745Reputation: 745
Quote:
Originally Posted by Habitual View Post
Sorry, uniq doesn't work that way. The entirety of each line is considered when using uniq.
I was wrong, Sorry.
http://www.bournetoraiseshell.com/ar...20622164348467

Last edited by Habitual; 06-22-2012 at 04:01 PM.
 
Old 06-22-2012, 03:52 PM   #7
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,565

Rep: Reputation: 410Reputation: 410Reputation: 410Reputation: 410Reputation: 410
My wording could have been better as well in regards to your post. I think we can move on from this now Habitual.

Alok did the above code give you the solution you were looking for?
 
1 members found this post helpful.
Old 06-25-2012, 08:23 AM   #8
Alok Behria
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Kustom42 View Post
My wording could have been better as well in regards to your post. I think we can move on from this now Habitual.

Alok did the above code give you the solution you were looking for?
Yes , indeed it worked !! for me... coudn't get the time on weekend... thanks very much ...
just curious to me , what w9 switch did here ??
 
Old 06-25-2012, 10:51 AM   #9
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,565

Rep: Reputation: 410Reputation: 410Reputation: 410Reputation: 410Reputation: 410
-w tells uniq the number of characters to compare, by default it will compare the entire line. Since the only unique value you wanted to compare was the ORA number which is 9 characters long you specify the -w with the number 9.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python, find unique values in a tuple or dictionary action_owl Programming 2 05-11-2010 07:16 PM
Show unique values with related data in one line cgcamal Programming 1 11-21-2008 02:48 AM
HOWTO access Processor ID / other unique values?? kartheekpn Linux - Security 5 03-20-2005 04:10 AM
how to use expr to print floating point values max_rsr Linux - Newbie 1 03-12-2005 10:00 PM
MySQL - UNIQUE values across two columns - non-standard constraint issue benr77 Linux - General 2 11-06-2004 10:48 AM


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

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