![]() |
| ||
| Duplicate lines in a text file How to print the duplicates in a text file. Also the line number where the duplicate text has been found needs to be printed. pls help KZ |
| ||
| Re: Duplicate lines in a text file Hi, If you are working in Unix then, Use following command <code> cat -n file-name > file_name2 </code> Then use <code> sort -u -k 2,4 file_name2 </code> |
| ||
| Re: Duplicate lines in a text file No, I am not working in Unix. I am working with Windows. KZ |
| ||
| Re: Duplicate lines in a text file Or use Uniq command <code> $ cat happybirthday.txt Happy Birthday to You! Happy Birthday to You! Happy Birthday Dear vinay! Happy Birthday to You! </code> <code> $ sort happybirthday.txt | uniq -dc 3 Happy Birthday to You! </code> |
| ||
| Re: Duplicate lines in a text file Quote:
|
| ||
| Re: Duplicate lines in a text file many a thanks msvinaykumar, i am looking for a perl script that works with windows. KZ |
| ||
| Re: Duplicate lines in a text file open(FILE,"1.txt") || die "$!"; ## 1.txt is a file name %seen =(); $line=0 ; while (<FILE>) { $seen{$_}++; $line++; print "$line : $_" if $seen{$_} > 1 ; } |
| ||
| Re: Duplicate lines in a text file thanks prakash, it did really work. also if you could provide help for a script that reads a blank line in a txt file and prints the line above the blank line. Eg abcdef william marc sumeet nair output: abcdef sumeet thanks in advance |
| ||
| Re: Duplicate lines in a text file At some point you should start doing your own school work and the rest of the people participating in this thread you stop doing it for you. |
| All times are GMT -4. The time now is 6:40 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC