Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How join two scripts into one?

Status
Not open for further replies.

gargamel100

Technical User
Oct 25, 2006
31
CZ
Hi people,

I have two scripts which works ok, but I wish I can join them into only one scripts. The scripts are
(first)
##############################################################
awk -F"|" '

BEGIN { print "" }
$21 == "28" && $9 == "90000555" {t=t+1}
$21 == "28" && $9 == "90007666" {z=z+1}
$21 == "28" && $9 == "90008777" {b=b+1}

END {print " 90000 ", t}
END {print " 90007 ", z}
END {print " 90008 ", b}'
# This one sort and print fields $9 into some file
# second script checking for first value and print $1 and $2
# this is ag example
#############################################################
(second)
###########################################################
awk '{if ($1~/90/) print $1 "\t" $2*1;
else
if($1~/91/) print $1 "\t" $2*2;
else
if($1~/92/) print $1 "\t" $2*3;}'
#############################################################

My question is how join script " first" and "second " in this case into one script?


Regards
 
first script has output like bellow ( two columns )

90000555----1
90007666----9
92008777----4

second script
90000 ---- 0
90007 ---- 9
92008 - ---- 3

If number starts in column one ( previous script ) with 90 then multiple its value by 1, 91 by 2, 92 by 3, and so on.
This works ok pipinig output of one script to input of other but I wish i can put all that into one script to work.

Regards


 
Well, you didn't provide the original input data so I can't test.

But... how can the first script ever output "92008" when it only has code to output 90000, 90007 and 90008? And if it only ever outputs those three values as the first field, then you don't need the cases for /91/ and /92/ in the second script because they will never occur.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top