Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Search for repeats in text file - how? Post 302070022 by vgersh99 on Thursday 30th of March 2006 02:49:47 PM
Old 03-30-2006
Quote:
Originally Posted by jim mcnamara
This stores the duplicate lines in a file = dup.lines
Code:
awk '{x[$0]++;                         
      if( x[$0] > 1) { print $0}       
     } ' filename > dup.lines

a slight modification - considering you don't want to print a line EVERY time the line is repeated.
Code:
awk '{x[$0]++}
       END { for (i in x)                      
                  if( x[i] > 1 ) { print x[i]}       
       } ' filename > dup.lines

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search and replace a specific text in text file?

I have a text file with following content (3 lines) filename : output.txt first line:12/12/2008 second line:12/12/2008 third line:Y I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before. I tried using cat output.txt... (4 Replies)
Discussion started by: santosham
4 Replies

2. Shell Programming and Scripting

Search for a text in a file

How can i get all the output that i wanted see example below. ex: Wed Nov 9 11111111111111 22222222222222 33333333333333 Thu Nov 10 aaaaaaaaaaaa bbbbbbbbbbbbbb ccccccccccccccc Wed Nov 9 44444444444 55555555555 aaaaaaaaaaa (13 Replies)
Discussion started by: kenshinhimura
13 Replies

3. Shell Programming and Scripting

Search text from a file and print text and one previous line too

Hi, Please let me know how to find text and print text and its previous line. Please don't get irritated few days back I asked text and next line. I am using HP-UX 11.11 Thanks for your help. (6 Replies)
Discussion started by: kamranjalal
6 Replies

4. Shell Programming and Scripting

How do I search on a text file?

Hi, I'm new to shell programming and I have a text file with data with looks like this: chocolate:toblerone swiss:23:100:20 chocolate:ferro rocher:30:90:80 gummi bear:gummi co:5:20:12 . It is basically a file which stores food. The 1st field is the type of food, 2nd... (4 Replies)
Discussion started by: mofako
4 Replies

5. Shell Programming and Scripting

search text file in file if this file contains necessary text (awk,grep)

Hello friends! Help me pls to write correct awk and grep statements for my task: I have got files with name filename.txt It has such structure: Start of file FROM: address@domen.com (12...890) abc DATE: 11/23/2009 on Std SUBJECT: any subject End of file So, I must check, if this file... (4 Replies)
Discussion started by: candyme
4 Replies

6. Shell Programming and Scripting

Search value in text file

Hi, I have the follwoing text file : db1;unrecoverable;0;20110728162548 db1;unrefreshed;1,NO_MV_VIEWS;20110728162548 xe1;Database;1;20110728162548 xe1;autoextensible;0;20110511112053 xe1;chk_offline_dbf;0;20110511112053 xe1;expiry_date;0;20110511112053 xe1;job;4;20110420111823... (2 Replies)
Discussion started by: yoavbe
2 Replies

7. Shell Programming and Scripting

Searching a large file for short tandem repeats

Hello, I am searching large (~25gb) DNA sequence data in fasta short read format: >ReadName ACGTACGTACGT... for short tandem repeats, meaning instances of any 2-6 character based run that are repeated in tandem a number of times given as an input variable. Seems like a reasonably simple... (3 Replies)
Discussion started by: ljk
3 Replies

8. Shell Programming and Scripting

Search text file

awk -F "" ' $2 ~ /<Clinical features:>|<Clinical features:>|<Inheritance pattern:>|<Inheritance pattern:>/{print $2, $3}' OFS='\t' genedx156.txt > output.txt The above command seems to run but no results are in the output. Basically, I am just searching for those key words and output the... (5 Replies)
Discussion started by: cmccabe
5 Replies

9. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

10. Shell Programming and Scripting

Search a text and return the text from file

Hi I have a set of input strings in a pattern as given below string1 string2 string3 string4 string5 I need to search this sequence of strings from a file in such a way that the first two strings (string1 and string2) and last two strings (string4 and string5) should match with the... (8 Replies)
Discussion started by: my_Perl
8 Replies
dup(2)								   System Calls 							    dup(2)

NAME
dup - duplicate an open file descriptor SYNOPSIS
#include <unistd.h> int dup(int fildes); DESCRIPTION
The dup() function returns a new file descriptor having the following in common with the original open file descriptor fildes: o same open file (or pipe) o same file pointer (that is, both file descriptors share one file pointer) o same access mode (read, write or read/write). The new file descriptor is set to remain open across exec functions (see fcntl(2)). The file descriptor returned is the lowest one available. The dup(fildes) function call is equivalent to: fcntl(fildes, F_DUPFD, 0) RETURN VALUES
Upon successful completion, a non-negative integer representing the file descriptor is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The dup() function will fail if: EBADF The fildes argument is not a valid open file descriptor. EINTR A signal was caught during the execution of the dup() function. EMFILE The process has too many open files (see getrlimit(2)). ENOLINK The fildes argument is on a remote machine and the link to that machine is no longer active. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
close(2), creat(2), exec(2), fcntl(2), getrlimit(2), open(2), pipe(2), dup2(3C), lockf(3C), attributes(5), standards(5) SunOS 5.10 28 Dec 1996 dup(2)
All times are GMT -4. The time now is 12:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy