Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Add numbers in third code with conditions on the 1st and 2nd Post 302883318 by TheTransporter on Monday 13th of January 2014 09:48:05 AM
Old 01-13-2014
Hey admin,

Thanks for the interest.

I have written the following code that works, but it significantly slow.

calling ./counter.sh

Code:
#!/bin/bash
awk '{print $1}' $1 > 1.txt
awk '{print $2}' $1 > 2.txt
awk '{print $3}' $1 > 3.txt
paste 1.txt 2.txt | tr '\t' '_' > non-reverse.txt
paste 2.txt 1.txt | tr '\t' '_'> reverse.txt
paste non-reverse.txt 3.txt > tt; mv tt non-reverse.txt
paste reverse.txt 3.txt > tt; mv tt reverse.txt
cat reverse.txt non-reverse.txt > duplicates.txt
cat duplicates.txt | sort -nk1 | uniq > tt; mv tt duplicates.txt
awk '{print $1}' duplicates.txt | sort -nk1 | uniq > pair
for i in `cat pair`; do echo $i >> tt ; grep $i duplicates.txt | awk '{ sum+=$2} END {print sum}' >> tt; done
mv tt added_duplicates.txt
sed '$!N;s/\n/,/' added_duplicates.txt  | sort -nk1 | uniq > tt; mv tt final.txt
cat final.txt | tr '_' ' ' | tr ',' ' ' | grep ^[A-Z]  > tt; mv tt final.txt
rm -rf added_duplicates.txt non-reverse.txt reverse.txt duplicates.txt pair added_duplicates

 

We Also Found This Discussion For You

1. UNIX for Dummies Questions & Answers

Want the UNIX code - I want to sum of the 1st column wherever the first 2nd and 3rd columns r equal

I have the code for the below things.. File1 has the content as below 8859 0 subscriberCreate 18 0 subscriberPaymentMethodChange 1650 0 subscriberProfileUpdate 7668 0 subscriberStatusChange 13 4020100 subscriberProfileUpdate 1 4020129 subscriberStatusChange 2 4020307 subscriberCreate 8831... (5 Replies)
Discussion started by: Mahen
5 Replies
grcompiler(1)															     grcompiler(1)

NAME
grcompiler - Compile GDL into a TrueType Font SYNOPSIS
grcompiler [-d] [-D] [-g] [-n number] [-v number] [-w number] [-wall] [-q] gdl-file font-file [output-file] [output-fontname] Description Grcompiler compiles a Graphite Description Language description of the smarts for a font along with a TrueType Font to create a graphite font with graphite tables in it. -d Generate XML debugger file. -D Generate all debugger files. -g Permit and ignore invalid glyph definitions. -nnumber Set name table start location. -q Quiet mode (no messages except on error). -vnumber Set Silf table version number. -wnnnn Ignore warning with the given number. This option may be repeated. -wall Display all warnings. Environment grcompiler makes use of the following environment variables GDLPP Specifies the command to execute to run the GDL preprocessor Files gdlerr.txt Warnings and errors are output to this file. dbg_classes.txt Debug file that specifies the classes stored in the font in terms of their GDL source and containing glyph ids in hex. dbg_cmap.txt Debug file giving Unicode to glyph mapping of all the glyphs in the font and vice versa. dbg_enginecode.txt Debug file containing the action code and constraint code associated with each pass and rule in a pass. dbg_fsm.txt Debug file that gives the finite state machines of each pass and the rules referenced. For each pass, a mapping is given between glyph and column number. dbg_glyphattrs.txt Debug file containing all the glyph attributes and their names, along with values specified for each glyph. dbg_parsetree.txt Debug file giving the complete parse tree of the GDL source file. dbg_ruleprec.txt Debug file that lists the rules in precedence order (order in which they will be tested) for each pass. $_temp.gdl Debug file containing the output of gdlpp Author Martin Hosken <mhosken@users.sourceforge.net> $Date: 2012-05-29 11:36:50 $ grcompiler(1)
All times are GMT -4. The time now is 01:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy