LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   print only unique values (https://www.linuxquestions.org/questions/linux-general-1/print-only-unique-values-4175412878/)

Alok Behria 06-22-2012 02:17 PM

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


Habitual 06-22-2012 02:38 PM

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

I was wrong, Sorry.

Kustom42 06-22-2012 02:42 PM

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.

Habitual 06-22-2012 03:43 PM

Quote:

Originally Posted by Kustom42 (Post 4709573)
[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.

Kustom42 06-22-2012 03:47 PM

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.

Habitual 06-22-2012 03:49 PM

Quote:

Originally Posted by Habitual (Post 4709568)
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

Kustom42 06-22-2012 03:52 PM

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?

Alok Behria 06-25-2012 08:23 AM

Quote:

Originally Posted by Kustom42 (Post 4709625)
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 ??

Kustom42 06-25-2012 10:51 AM

-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.


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