The UNIX and Linux Forums  


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 06: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 05: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 Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 3 votes, 4.33 average. Display Modes
  #1 (permalink)  
Old 12-01-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Looking at this thread, hellsd, we are never going to get a solution as you haven't posted what output you expect to achieve.

Please post something along the lines of....

"my original file is
.
.
10 lines of input
.
.

I expect to get
.
.
10 lines of output
.
.
"

I cannot see exactly what you are trying to get?! Which algorithm are you trying to formulate (i.e. you say you want to keep the original case, but where you have KEVIN and kevin, and want only one of these case variations, which is the correct case variation you wish to keep), etc....

Cheers
ZB
  #2 (permalink)  
Old 12-01-2004
hellsd hellsd is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 20
Ok. sorry, here you go

Input file:

line 1: David, password: ab4TkN
line 2: Kevin, password: kRq5
line 3: kevin, PASSWORD: kRq5
line 4: abcd
line 5: efgh
line 6: ABCD
line 7: efgh

Output file:
line 1: David, password: ab4TkN


Explaination:
This i s a part of the unix process I wrote. When I get a file that contain duplicate lines:
1. I need to present in another file(or in the same file) only the uniq lines as they appear in the original Input file

2. The uniq -u doesn't ignore case - So this is the main problem, I guess.

Thanks again and I hope my message is clear now.

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

Join Date: Sep 2004
Location: USA
Posts: 511
here u go .......

#!/usr/bin/ksh

cat file1 | tr -s " " | cut -d":" -f 2 | tr "[A-Z]" "[a-z]" | sort | uniq -u > file2

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

Join Date: Nov 2004
Posts: 20
Last time I hope...

I call to your script runIt
I replace file1 with $1

Now I run it:
runIt file1

Output:

I get file2 with the correct lines, but they are all in lowercase.

I look at the unix console and it prints the Original file1 content and then the correct result.

How can I get the correct output in a new file.

*I am running on solaris machine, tcsh.
Thanks
  #5 (permalink)  
Old 12-01-2004
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
runit file1 > file3
  #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
See the change cut -d":" -f 2-



#!/usr/bin/ksh

cat $1 | tr -s " " | cut -d":" -f 2- | tr "[A-Z]" "[a-z]" | sort | uniq -u > file2

while read line
do
grep -i "$line" $1
done < file2
  #7 (permalink)  
Old 12-01-2004
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Using awk to print only unique lines...

awk '{x=tolower($0);a[x]++;b[x]=$0}END{for(x in a)if(a[x]==1)print b[x]}' file1 > file2

Tested on the sample data...

David, password: ab4TkN
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 08:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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