Sponsored Content
Top Forums Shell Programming and Scripting Get the average of lines with the same first 4 letters Post 303021747 by kenshinhimura on Wednesday 15th of August 2018 08:27:09 PM
Old 08-15-2018
Code:
$ cat hhhh
aaabbb1a 4000
aaabbb1g 2000
aaabbb1f 8000
baabbb4f 5000
baabbb4d 1000
baabbb4s 9000
cddbbbg1 10000
cddbbbg3 11000
cddbbbge 3000

##sh ave.sh

aaabbb1a 4000
aaabbb1g 2000
aaabbb1f 8000

Total Sum of aaabbb1 site is: 8000 Mbps

Total Average of aaabbb1 site is: 2666 Mbps

=======================
baabbb4f 5000
baabbb4d 1000
baabbb4s 9000

Total Sum of baabbb4 site is: 9000 Mbps

Total Average of baabbb4 site is: 3000 Mbps

=======================
cddbbbg1 10000
cddbbbg3 11000
cddbbbge 3000

Total Sum of cddbbbg site is: 3000 Mbps

Total Average of cddbbbg site is: 1000 Mbps
$

ill try different combination...not working right

------ Post updated at 07:27 PM ------

Never mind..thank you sir. I figured it out.. THank you for the comments..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

transposing letters

Hi, I've written a shell function in bash that reads letters into an array, then outputs them in one column with: for n in "${array}"; do echo $n done I was wondering if anyone knew how i would transpose the letters that are output by the for loop. Right now my output is: aabbcc... (4 Replies)
Discussion started by: myscsa2004
4 Replies

2. Shell Programming and Scripting

need to delete lines that start with letters

Hi, I need to remove all lines from a file that do not start with numbers For instance, if the first three characters on any line are not numbers, delete those lines I've tried to do it with awk and it's not working, any ideas ? Thanks (5 Replies)
Discussion started by: sfisk
5 Replies

3. UNIX for Advanced & Expert Users

Add letters

I want to add letters A,B,C,… in front of every line of input while printing them out using PERL. eg A file is parsed as a cmd line arg and its context will be displayed as A line1... B line 2.. I tried this..but I want better and perfect solution! !perl -p my $counter; BEGIN { $counter... (4 Replies)
Discussion started by: aadi_uni
4 Replies

4. Shell Programming and Scripting

print running field average for a set of lines

Hi everyone, I have a program that generates logs that contains sections like this: IMAGE INPUT 81 0 0.995 2449470 0 1726 368 1 0.0635 0.3291 82 0 1.001 2448013 0 1666 365 1 0.0649 0.3235 83 0 1.009 2444822 0 1697 371 1 ... (3 Replies)
Discussion started by: euval
3 Replies

5. Shell Programming and Scripting

Perl- Finding average "frequency" of occurrence of duplicate lines

Hello, I am working with a perl script that tries to find the average "frequency" in which lines are duplicated. So far I've only managed to find the way to count how many times the lines are repeated, the code is as follows: perl -ae' my $filename= $ENV{'i'}; open (FILE, "$filename") or... (10 Replies)
Discussion started by: acsg
10 Replies

6. Shell Programming and Scripting

How to add lines of a file and average them

I'm reading in numbers from a file and trying to add them together. Here is the code so far. I know the 1+2+3.... part is wrong. The file has five numbers in it with each number on its own line. The numbers are decimals if that matters. Thanks. while read EachLine do echo $EachLine done <... (6 Replies)
Discussion started by: AxlVanDamme
6 Replies

7. Shell Programming and Scripting

Randomize letters

Hi, Is there a tool somewhat parallel to rev, but which randomizes instead of reverses? I've tried rl, but I can only get it to randomize words. I was hoping for something like this echo "hello" | ran leolh less simpler solutions are also welcome. Sorry if the question is... (21 Replies)
Discussion started by: jeppe83
21 Replies

8. Shell Programming and Scripting

Combine identical lines and average the one variable field

I have the following file 299899 chrX_299716_300082 196 78.2903 299991 chrX_299982_300000 18.2538 Tajd:0.745591 FayWu:-0.245701 T2:1.45 299899 chrX_299716_300082 196 78.2903 299991 chrX_299982_300000 18.2538 Tajd:0.745591 FayWu:-0.245701 T2:0.283 311027 chrX_310892_311162 300 91.6452... (2 Replies)
Discussion started by: jfern
2 Replies

9. UNIX for Beginners Questions & Answers

Random letters

Hi there, first of all this is not homework...this is a new type of exercise for practicing vocabulary with my students. I have a file consisting of two columns, separated by a tab, each line consisting of a word and its definition, separated by a line break. What i need is to replace a... (15 Replies)
Discussion started by: eldeingles
15 Replies

10. UNIX for Beginners Questions & Answers

awk to average matching lines in file

The awk below executes and is close (producing the first 4 columns in desired). However, when I add the sum of $7, I get nothing returned. Basically, I am trying to combine all the matching $4 in f1 and output them with the average of $7 in each match. Thank you :). f1 ... (2 Replies)
Discussion started by: cmccabe
2 Replies
igb(7D) 							      Devices								   igb(7D)

NAME
igb - Intel 82575 1Gb PCI Express NIC Driver SYNOPSIS
/dev/igb* DESCRIPTION
The igb Gigabit Ethernet driver is a multi-threaded, loadable, clonable, GLD-based STREAMS driver supporting the Data Link Provider Interface, dlpi(7P), on Intel 82575 Gigabit Ethernet controllers. The igb driver functions include controller initialization, frame transmit and receive, promiscuous and multicast support, and error recovery and reporting. The igb driver and hardware support auto-negotiation, a protocol specified by the 1000 Base-T standard. Auto-negotiation allows each device to advertise its capabilities and discover those of its peer (link partner). The highest common denominator supported by both link partners is automatically selected, yielding the greatest available throughput, while requiring no manual configuration. The igb driver also allows you to configure the advertised capabilities to less than the maximum (where the full speed of the interface is not required), or to force a specific mode of operation, irrespective of the link partner's advertised capabilities. APPLICATION PROGRAMMING INTERFACE
The cloning character-special device, /dev/igb, is used to access all Intel 82575 Gigabit devices installed within the system. The igb driver is managed by the dladm(1M) command line utility, which allows VLANs to be defined on top of igb instances and for igb instances to be aggregated. See dladm(1M) for more details. You must send an explicit DL_ATTACH_REQ message to associate the opened stream with a particular device (PPA). The PPA ID is interpreted as an unsigned integer data type and indicates the corresponding device instance (unit) number. The driver returns an error (DL_ERROR_ACK) if the PPA field value does not correspond to a valid device instance number for the system. The device is initialized on first attach and de- initialized (stopped) at last detach. The values returned by the driver in the DL_INFO_ACK primitive in response to your DL_INFO_REQ are: o Maximum SDU is 9000. o Minimum SDU is 0. o DLSAP address length is 8. o MAC type is DL_ETHER. o SAP (Service Access Point) length value is -2, meaning the physical address component is followed immediately by a 2-byte SAP component within the DLSAP address. o Broadcast address value is the Ethernet/IEEE broadcast address (FF:FF:FF:FF:FF:FF). Once in the DL_ATTACHED state, you must send a DL_BIND_REQ to associate a particular SAP with the stream. CONFIGURATION
By default, the igb driver performs auto-negotiation to select the link speed and mode. Link speed and mode can be any one of the follow- ing, (as described in the IEEE803.2 standard): 1000 Mbps, full-duplex. 100 Mbps, full-duplex. 100 Mbps, half-duplex. 10 Mbps, full-duplex. 10 Mbps, half-duplex. The auto-negotiation protocol automatically selects speed (1000 Mbps, 100 Mbps, or 10 Mbps) and operation mode (full-duplex or half-duplex) as the highest common denominator supported by both link partners. Alternatively, you can set the capabilities advertised by the igb device using ndd(1M). The driver supports a number of parameters whose names begin with adv_ (see below). Each of these parameters contains a boolean value that determines if the device advertises that mode of operation. For example, the adv_1000fdx_cap parameter indicates if 1000M full duplex is advertised to link partner. The adv_autoneg cap parameter controls whether auto-negotiation is performed. If adv_autoneg_cap is set to 0, the driver forces the mode of operation selected by the first non-zero parameter in priority order as shown below: (highest priority/greatest throughput) adv_1000fdx_cap 1000Mbps full duplex adv_100fdx_cap 100Mpbs full duplex adv_100hdx_cap 100Mbps half duplex adv_10fdx_cap 10Mpbs full duplex adv_10hdx_cap 10Mpbs half duplex (lowest priority/least throughput) All capabilities default to enabled. Note that changing any capability parameter causes the link to go down while the link partners renego- tiate the link speed/duplex using the newly changed capabilities. FILES
/dev/igb* Special character device. /kernel/drv/igb 32-bit device driver (x86). /kernel/drv/amd64/igb 64-bit device driver (x86). /kernel/drv/sparcv9/igb 64-bit device driver (SPARC). /kernel/drv/igb.conf Configuration file. SEE ALSO
dladm(1M), ndd(1M), netstat(1M), driver.conf(4), attributes(5), streamio(7I), dlpi(7P), Writing Device Drivers STREAMS Programming Guide Network Interfaces Programmer's Guide SunOS 5.11 20 Jul 2007 igb(7D)
All times are GMT -4. The time now is 05:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy