The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Ignore Duplicate Post iago UNIX for Dummies Questions & Answers 0 09-04-2007 05:29 AM
removing duplicate lines from a file ocelot UNIX for Dummies Questions & Answers 4 01-25-2007 11:02 AM
Ignore case sensitive in Case Switch annelisa Shell Programming and Scripting 1 07-13-2006 04:36 AM
Ignore Case in Shell AAH Shell Programming and Scripting 3 03-21-2006 04:41 PM
How can I ignore only the lines which have # at the begining? csaha Shell Programming and Scripting 1 01-30-2006 03:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 3 votes, 4.33 average. Display Modes
  #1 (permalink)  
Old 12-01-2004
hellsd hellsd is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 20
Removing duplicate lines ignore case

hi,

I have the following input in file:
abc
ab
a
AB
b
c
a
C
B
When I use uniq -u file,the out put file is:
abc
ab
AB
c
v
B
C
b

Unfortunately, the uniq is not able to ignore case.

How can I check the file in order my output file will be:
abc
v

Thanks, Roy.
  #2 (permalink)  
Old 12-01-2004
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
convert into upper case or lower case and do sort ....


cat file1 | tr "[a-z]" "[A-Z]" | sort -u
  #3 (permalink)  
Old 12-01-2004
hellsd hellsd is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 20
It is not good

Because then I will lose the real values in the original file and the data I will get will be like converted (from lower to upper or and vice versia), because the input in file can be for example: "RsdA" and it has meaning


I thought there is a special/smart uniq that can do it.
Does anyone know how to do it?
Anyway, Thanks.
  #4 (permalink)  
Old 12-01-2004
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
-----------------------------------------
Posted by hellsd:

Because then I will lose the real values in the original file
-----------------------------------------------------------


We are not changing the data in original file ; o/p u can redirect to some other file.
  #5 (permalink)  
Old 12-01-2004
hellsd hellsd is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 20
I still don't get it, look at my example

file1 contain:
danIel
Kevin
DON
KEVIN
don

If I run your command as the following :
cat file1 | tr "[a-z]" "[A-Z]" | sort -u >outputFile
outPutFile contain:
DANIEL
DON
KEVIN

And this is not what I expect:
I need that the output will contain:
danIel

This is why I use uniq -u but it doesn't ignore case.

Thanks,

Roy.
  #6 (permalink)  
Old 12-01-2004
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
I hope following small script will solve yr prblem ;


#!/usr/bin/ksh

cat file1 | tr "[A-Z]" "[a-z]" | sort | uniq -u > file2

while read line
do
grep -i $line file1
done < file2
  #7 (permalink)  
Old 12-01-2004
hellsd hellsd is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 20
still doesn't solve my problem

Your script is great but it doesn't answer my question.

I need to keep the exact uniq content I have in the original file:
(suppose That each line has a pssword which is case sensetive)

So if my input file1 contain:
DAVID, aaBBCC
don, abcDk
kevin
KEVIN
DON, aBcDk

When I activate your script, I get:
david aabbcc
(line case was change)

And this is not what I need, I except to have the exact uniq content:
DAVID, aaBBCC

Again, thank you very much for your efforts and I hope that I will finally have a solution for it.

Roy
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0