Sponsored Content
Top Forums Shell Programming and Scripting compare columns for equal values and output a summary Post 302498193 by reno on Sunday 20th of February 2011 11:33:13 AM
Old 02-20-2011
compare columns for equal values and output a summary

Hi all

I am trying to scan a file that has 3 columns:

red blue 123351
red blue 848655
red blue 126354
red blue 023158
black white 654896
red blue 650884

I want an output that sums the rows that have matching columns 1 and 2 Smilie


red blue has 5 entries
black white has 1 entry


Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Aggregate values in a file & compare with sql output

Hi, I have a file containing the following data: junk123junk723itemcode001qty01price10total10junkjunk junk123junk723itemcode002qty02price10total20junkjunk .. .. .. could be 5000+ lines I have an algo and need a code to implement this: 1. Linecount = wc -l (should give 5000) 2. For i... (1 Reply)
Discussion started by: shiroh_1982
1 Replies

2. Shell Programming and Scripting

compare columns from seven files and print the output

Hi guys, I need some help to come out with a solution . I have seven such files but I am showing only three for convenience. filea a5 20 a8 16 fileb a3 42 a7 14 filec a5 23 a3 07 The output file shoud contain the data in table form showing first field of... (7 Replies)
Discussion started by: smriti_shridhar
7 Replies

3. Shell Programming and Scripting

My Values are Equal but They are Not

Does anybody understand why this is not being interpreted as true. Script: #!/bin/bash errored=`grep "errored" new_update_scripts.txt` echo $errored = "errored" if ; then echo true else echo false fi Output: $ UpdateScripts errored = errored false (7 Replies)
Discussion started by: scottwmackey
7 Replies

4. Shell Programming and Scripting

sending field values in columns to output file

Hi, I am trying to send output from a shell scrip to a txt file in a colum format. I have all I can and I dont seem to understand why the results from one one particular file keeps going to the next line. How can I force all to be in one line Please see code and output below The is... (0 Replies)
Discussion started by: asemota
0 Replies

5. Shell Programming and Scripting

How to compare particular string, if it is equal put into a new file

Hi, I have a file (sample.txt) this file contains below text. ./au ./11.5.0 ./11.5.0/admin ./11.5.0/admin/driver ./po ./11.5.0 ./11.5.0/admin ./11.5.0/admin/driver ./xxsbx/11.5.0/java/src ./xxsbx/11.5.0/lib ./xxsel ./xxsel/11.5.0 ./xxsel/11.5.0/admin ./zfa ./zfa/11.5.0... (2 Replies)
Discussion started by: gagan4599
2 Replies

6. Shell Programming and Scripting

awk compare 2 columns, 2 files, output whole line

Hello, I have not been able to find what I'm looking for via searching the forum. I could use some help with an awk script or one-liner to solve this simple problem. I have two files. If $1 and $2 from file1 match $1 and $2 from file2, print the whole line from file2. Example file1 ... (2 Replies)
Discussion started by: jm4smtddd
2 Replies

7. UNIX for Dummies Questions & Answers

Replacing values in a column if they equal a certain value

Hi, I have a tab delimited text file where some lines have the string "NA" in the second column. For these lines, I want to replace NA with the value in the first column, the symbol underscore followed by the value in the fourth column. How do I go about doing that? Thanks! Input: 1 ... (3 Replies)
Discussion started by: evelibertine
3 Replies

8. Shell Programming and Scripting

Compare columns of multiple files and print those unique string from File1 in an output file.

Hi, I have multiple files that each contain one column of strings: File1: 123abc 456def 789ghi File2: 123abc 456def 891jkl File3: 234mno 123abc 456def In total I have 25 of these type of file. (5 Replies)
Discussion started by: owwow14
5 Replies

9. UNIX for Beginners Questions & Answers

Awk: compare values in two columns of the same file

I'm trying to learn awk, but I've hit a roadblock with this problem. I have a hierarchy stored in a file with 3 columns: id name parentID 4 D 2 2 B 1 3 C 1 1 A 5 I need to check if there are any values in column 3 that are not represented anywhere in column 1. I've tried this: awk '{arr;}... (7 Replies)
Discussion started by: kaktus
7 Replies

10. Shell Programming and Scripting

How to print out with equal spacing between columns?

For instance, my file contains the following content... set -A array set -A test ${array}=1 ${array}=2 ${array}=3 ${test}="Boy" ${test}="Girl" ${test}="Dog" x=0 while ;do print "${array}" " " "${test}" x=$((x+1) done... (1 Reply)
Discussion started by: TestKing
1 Replies
DwtColorMixSetNewColor(3Dwt)											      DwtColorMixSetNewColor(3Dwt)

Name
       DwtColorMixSetNewColor - Sets the new red, green, and blue color values in the color mixing widget.

Syntax
       void DwtColorMixSetNewColor(cmw, red, green, blue)
	    Widget cmw;
	    unsigned short red;
	    unsigned short green;
	    unsigned short blue;

Arguments
       cmw	 Specifies the widget ID of the color mixing widget.

       red	 Specifies the new color red value.  You can express the value in percentages or by the X color values (0 to 65535).

       green	 Specifies the new color green value.  You can express the value in percentages or by the X color values (0 to 65535).

       blue	 Specifies the new color blue value.  You can express the value in percentages or by the X color values (0 to 65535).

		 See  the  section on colormap functions in the Guide to the Xlib Library: C Language Binding for more information on X color val-
		 ues.

Description
       The DwtColorMixSetNewColor function allows the user-supplied color mixer subwidget to pass the current color values  to	the  color  mixing
       widget.	Using DwtColorMixSetNewColor is more efficient than using XtSetValues.

See Also
       DwtColorMixGetNewColor(3Dwt), DwtColorMixCreate(3Dwt)
       Guide to the XUI Toolkit: C Language Binding
       Guide to the XUI Toolkit Intrinsics: C Language Binding

														      DwtColorMixSetNewColor(3Dwt)
All times are GMT -4. The time now is 07:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy