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
text file editing injeti Shell Programming and Scripting 26 06-04-2008 11:11 AM
Building Full-Text Search Applications with Oracle Text iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
Text editing on iPhone using ed drewcifer UNIX for Dummies Questions & Answers 1 03-05-2008 07:15 PM
Cons: Configuration is done by editing the text-based config file ... - Techworld.com iBot UNIX and Linux RSS News 0 10-09-2007 09:10 AM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 02:50 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-19-2006
ginodii ginodii is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 5
Text Editing

Hello everybody,

I have a sorted text file. some of the lines appear twice or even more. is there an unix utility that removes the extra appearences?

Thanks,
Ido.
  #2 (permalink)  
Old 10-19-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 578
Try uniq command. Check man uniq for more help.
  #3 (permalink)  
Old 10-19-2006
ginodii ginodii is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 5
Thanks!
Ido.

Last edited by ginodii; 10-19-2006 at 08:07 AM..
  #4 (permalink)  
Old 10-19-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 578
Quote:
Originally Posted by ginodii
10x!
You are welcome!

Since you are new to these forums, I would recommend you to read the RULES we practice here:

(9) Edit your posts if you see spelling or grammar errors (don't write in cyberchat or cyberpunk style). English only.

Regards,
Tayyab
  #5 (permalink)  
Old 10-19-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
uniq wont work coz it only removes the repeated line if they come one after the other

if the file is like the following

ab
hjk
jl as
ab

it wont work.

i know its not the ans u want, but i am working on it.
  #6 (permalink)  
Old 10-19-2006
ginodii ginodii is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 5
Its okay coz anyway I sort the file in advance...

Thanks,
Ido.
  #7 (permalink)  
Old 10-19-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
there is some minor defect with this code. i think the logic is ok. someone plz try n debug it. i am doing it in a hurry n hv to go now.

#!/bin/awk -f~
cat bc|while read line
do
x=`wc -l bc|awk '{print $1}'`
for ( k=( NR + 1 ) ; k<=x ; k++ )
{
if /$line/
then
sed 'k d' bc
fi
}
done



error:


awk: syntax error near line 2
awk: bailing out near line 2
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 12:24 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