Which command can help me output lines with duplicate numbers?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Which command can help me output lines with duplicate numbers?
# 1  
Old 08-11-2010
Which command can help me output lines with duplicate numbers?

i have a file, let's call it file.

march 2008 january 2008
march 1920 march 2002

i want to output the first line, not the second as you can see the second line has different numbers.
# 2  
Old 08-11-2010
Try...
Code:
awk '$2==$4' file

This User Gave Thanks to Ygor For This Post:
# 3  
Old 08-11-2010
my file contains:
march 2008 january 2008
march 1920 march 2002

awk ' $2==$4 ' filename
no output.
# 4  
Old 08-11-2010
Code:
awk ' $2==$4 ' filename

It should provide what you require. if the fields are seperated by tab you must use

Code:
awk '$2==$4' FS=\t filename

-Raja
This User Gave Thanks to rajamadhavan For This Post:
# 5  
Old 08-11-2010
Hmm, works here. What OS are you using?

Does
Code:
awk '$2 == $4 { print; }' filename

work? If you have nawk or gawk, try this.
This User Gave Thanks to hergp For This Post:
# 6  
Old 08-11-2010
i got putty installed on windows xp.

awk '$2==$4' FS=\t filename
this is the only one which gave an output but displays both lines.

i tried awk '$2==$4' filename
awk ' $2==$4 ' filename
awk '$2 == $4' filename
awk '$2 == $4 { print; }' filename
something wrong in my system i guess.
# 7  
Old 08-11-2010
To find the OS, run uname -a on your putty terminal..

Code:
awk '{if($2==$4) print}' FS=" " filename

This User Gave Thanks to rajamadhavan For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to put the command to remove duplicate lines in my awk script?

I create a CGI in bash/html. My awk script looks like : echo "<table>" for fn in /var/www/cgi-bin/LPAR_MAP/*; do echo "<td>" echo "<PRE>" awk -F',|;' -v test="$test" ' NR==1 { split(FILENAME ,a,""); } $0 ~ test { if(!header++){ ... (12 Replies)
Discussion started by: Tim2424
12 Replies

2. Shell Programming and Scripting

AWK Command to duplicate lines in a file?

Hi, I have a file with date in it like: UserString1 UserString2 UserString3 UserString4 UserString5 I need two entries for each line so it reads like UserString1 UserString1 UserString2 UserString2 etc. Can someone help me with the awk command please? Thanks (4 Replies)
Discussion started by: Grueben
4 Replies

3. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

4. UNIX for Dummies Questions & Answers

How to parse 2 particular lines from Command output

Hi All, I need help on the following req. I am getting output of a command as follows: 16377612 total memory 3802460 used memory 2827076 active memory 681948 inactive memory 12575152 free memory 477452 buffer memory I want to compute used... (1 Reply)
Discussion started by: mailsara
1 Replies

5. Shell Programming and Scripting

How to cut selected lines from command output

Hi guys, I need to cut the first 12 system processes from the command ps -A. I know that the cut command forms part of the pipeline but can't understand how to cut the first 12 lines and later display them on standard output. Please help! Many thanks, Jared. (3 Replies)
Discussion started by: jjb1989
3 Replies

6. Shell Programming and Scripting

Command to remove duplicate lines with perl,sed,awk

Input: hello hello hello hello monkey donkey hello hello drink dance drink Output should be: hello hello monkey donkey drink dance (9 Replies)
Discussion started by: cola
9 Replies

7. Shell Programming and Scripting

Print duplicate only lines as normal output - Awk

input output a1 100 200 XYZ_X a1 98 188 ABC (2 Replies)
Discussion started by: quincyjones
2 Replies

8. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

9. Shell Programming and Scripting

Command/Script to remove duplicate lines from the file?

Hello, Can anyone tell Command/Script to remove duplicate lines from the file? (2 Replies)
Discussion started by: Rahulpict
2 Replies

10. Shell Programming and Scripting

Add text before lines in command output

Hi2all, I have following command in IBM HMC console: lssyscfg -r prof -m Server-9117-MMA-SN655D350 -F lpar_name,min_mem,desired_mem --header which gives me the following output: lpar_name,min_mem,desired_mem lpar1,1024,2048 lpar2,1024,2048 lpar3,2048,4096 What I want is to add in... (3 Replies)
Discussion started by: UsRb
3 Replies
Login or Register to Ask a Question