Sponsored Content
Full Discussion: Divide the numbers in file
Top Forums Shell Programming and Scripting Divide the numbers in file Post 302995900 by gnulyn on Friday 14th of April 2017 12:32:11 PM
Old 04-14-2017
Thanks for vgersh99

Code:
[root@localhost ~]# ./forum.sh
tx_bytes: 2422,
tx_packets: 13,
uptime: 04:28,

tx_bytes: 2342,
tx_packets: 14,
uptime: 03:03,

tx_bytes: 252,
tx_packets: 12,
uptime: 00:51,
[root@localhost ~]#


Last edited by Don Cragun; 04-14-2017 at 09:29 PM.. Reason: Add CODE tags again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

divide a single file with different Weboffercodes into different files with each of o

Here is the format of my file; I do not have the delimiter in the file for the data to be separated. Each line in the file is in the following format. File contains the data of different WebOfferCodes Item Code | Account Number | Card Number | Source code | WebOfferCode 12digits | 10... (4 Replies)
Discussion started by: enigma_83
4 Replies

2. 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

3. Shell Programming and Scripting

Divide the file into several Variable

I have a file, let's say X BTS 0 UNLOCKED ENABLED NONE TRX 0 UNLOCKED ENABLED NONE TRX 1 UNLOCKED ENABLED NONE BTS 1 UNLOCKED ENABLED NONE TRX 0 UNLOCKED ENABLED NONE... (4 Replies)
Discussion started by: amaulana
4 Replies

4. Shell Programming and Scripting

Divide numbers into intervals

divide input values into specified number (-100 or -200) according to the key (a1 or a2 ....) For ex: if we give -100 in the command line it would create 100 number intervals (1-100, 100-200, 200-300) untill it covers the value 300 in a1. Note: It should work the same even with huge numbers... (3 Replies)
Discussion started by: ruby_sgp
3 Replies

5. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

6. Shell Programming and Scripting

Add and divide each numbers with the added number

Hi All, I am stuck with this problem. I have some 100000 (.dat) 1.dat, 2.dat,3.dat etc until 100000.dat files which look like this: 1.dat 1 2 3 4 0.99 4.54 All my files 1.dat until 100000.dat look the same but with different numbers. I have to first add all the numbers in each... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. UNIX for Dummies Questions & Answers

divide the file into multiple files based on the city name

Hi, I have a file abc.dat. It contains the fileds of empid, empname, empcity. each city contains 10 records. i want to create the city file and pass the same city records into the file. I don't know the city names. In unix using awk command how can we do? abc.dat: 1 john delhi 2... (2 Replies)
Discussion started by: raghukreddy.ab
2 Replies

8. Shell Programming and Scripting

Adding (as in arithmetic) to numbers in columns in file, and writing new file with new numbers

Hi again. Sorry for all the questions — I've tried to do all this myself but I'm just not good enough yet, and the help I've received so far from bartus11 has been absolutely invaluable. Hopefully this will be the last bit of file manipulation I need to do. I have a file which is formatted as... (4 Replies)
Discussion started by: crunchgargoyle
4 Replies

9. UNIX for Dummies Questions & Answers

To divide file

We have large log files, and we need to extract last four hours lines only, Please let us know the command. Thanks, Saurau. (1 Reply)
Discussion started by: saurau
1 Replies

10. Shell Programming and Scripting

Script to divide/expand first digit to show some numbers

Hello to everyone, I have this complex problem and I don't how to do it. I'm not sure if awk could be a good choice to do it or could be easiest in bash or perl. A kind of introduction would be: - I have a digit, lets say 3. - I can expand/spread out the digit 3 to cover all possible... (7 Replies)
Discussion started by: Ophiuchus
7 Replies
GETIFADDRS(3)						     Linux Programmer's Manual						     GETIFADDRS(3)

NAME
getifaddrs, freeifaddrs - get interface addresses SYNOPSIS
#include <sys/types.h> #include <ifaddrs.h> int getifaddrs(struct ifaddrs **ifap); void freeifaddrs(struct ifaddrs *ifa); DESCRIPTION
The getifaddrs() function creates a linked list of structures describing the network interfaces of the local system, and stores the address of the first item of the list in *ifap. The list consists of ifaddrs structures, defined as follows: struct ifaddrs { struct ifaddrs *ifa_next; /* Next item in list */ char *ifa_name; /* Name of interface */ unsigned int ifa_flags; /* Flags from SIOCGIFFLAGS */ struct sockaddr *ifa_addr; /* Address of interface */ struct sockaddr *ifa_netmask; /* Netmask of interface */ union { struct sockaddr *ifu_broadaddr; /* Broadcast address of interface */ struct sockaddr *ifu_dstaddr; /* Point-to-point destination address */ } ifa_ifu; #define ifa_broadaddr ifa_ifu.ifu_broadaddr #define ifa_dstaddr ifa_ifu.ifu_dstaddr void *ifa_data; /* Address-specific data */ }; The ifa_next field contains a pointer to the next structure on the list, or NULL if this is the last item of the list. The ifa_name points to the null-terminated interface name. The ifa_flags field contains the interface flags, as returned by the SIOCGIFFLAGS ioctl(2) operation (see netdevice(7) for a list of these flags). The ifa_addr field points to a structure containing the interface address. (The sa_family subfield should be consulted to determine the format of the address structure.) This field may contain a null pointer. The ifa_netmask field points to a structure containing the netmask associated with ifa_addr, if applicable for the address family. This field may contain a null pointer. Depending on whether the bit IFF_BROADCAST or IFF_POINTOPOINT is set in ifa_flags (only one can be set at a time), either ifa_broadaddr will contain the broadcast address associated with ifa_addr (if applicable for the address family) or ifa_dstaddr will contain the destina- tion address of the point-to-point interface. The ifa_data field points to a buffer containing address-family-specific data; this field may be NULL if there is no such data for this interface. The data returned by getifaddrs() is dynamically allocated and should be freed using freeifaddrs() when no longer needed. RETURN VALUE
On success, getifaddrs() returns zero; on error, -1 is returned, and errno is set appropriately. ERRORS
getifaddrs() may fail and set errno for any of the errors specified for socket(2), bind(2), getsockname(2), recvmsg(2), sendto(2), mal- loc(3), or realloc(3). VERSIONS
The getifaddrs() function first appeared in glibc 2.3, but before glibc 2.3.3, the implementation supported only IPv4 addresses; IPv6 sup- port was added in glibc 2.3.3. Support of address families other than IPv4 is available only on kernels that support netlink. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------------------------+---------------+---------+ |Interface | Attribute | Value | +----------------------------+---------------+---------+ |getifaddrs(), freeifaddrs() | Thread safety | MT-Safe | +----------------------------+---------------+---------+ CONFORMING TO
Not in POSIX.1. This function first appeared in BSDi and is present on the BSD systems, but with slightly different semantics documented-- returning one entry per interface, not per address. This means ifa_addr and other fields can actually be NULL if the interface has no address, and no link-level address is returned if the interface has an IP address assigned. Also, the way of choosing either ifa_broadaddr or ifa_dstaddr differs on various systems. NOTES
The addresses returned on Linux will usually be the IPv4 and IPv6 addresses assigned to the interface, but also one AF_PACKET address per interface containing lower-level details about the interface and its physical layer. In this case, the ifa_data field may contain a pointer to a struct rtnl_link_stats, defined in <linux/if_link.h> (in Linux 2.4 and earlier, struct net_device_stats, defined in <linux/netdevice.h>), which contains various interface attributes and statistics. EXAMPLE
The program below demonstrates the use of getifaddrs(), freeifaddrs(), and getnameinfo(3). Here is what we see when running this program on one system: $ ./a.out lo AF_PACKET (17) tx_packets = 524; rx_packets = 524 tx_bytes = 38788; rx_bytes = 38788 wlp3s0 AF_PACKET (17) tx_packets = 108391; rx_packets = 130245 tx_bytes = 30420659; rx_bytes = 94230014 em1 AF_PACKET (17) tx_packets = 0; rx_packets = 0 tx_bytes = 0; rx_bytes = 0 lo AF_INET (2) address: <127.0.0.1> wlp3s0 AF_INET (2) address: <192.168.235.137> lo AF_INET6 (10) address: <::1> wlp3s0 AF_INET6 (10) address: <fe80::7ee9:d3ff:fef5:1a91%wlp3s0> Program source #define _GNU_SOURCE /* To get defns of NI_MAXSERV and NI_MAXHOST */ #include <arpa/inet.h> #include <sys/socket.h> #include <netdb.h> #include <ifaddrs.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <linux/if_link.h> int main(int argc, char *argv[]) { struct ifaddrs *ifaddr, *ifa; int family, s, n; char host[NI_MAXHOST]; if (getifaddrs(&ifaddr) == -1) { perror("getifaddrs"); exit(EXIT_FAILURE); } /* Walk through linked list, maintaining head pointer so we can free list later */ for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { if (ifa->ifa_addr == NULL) continue; family = ifa->ifa_addr->sa_family; /* Display interface name and family (including symbolic form of the latter for the common families) */ printf("%-8s %s (%d) ", ifa->ifa_name, (family == AF_PACKET) ? "AF_PACKET" : (family == AF_INET) ? "AF_INET" : (family == AF_INET6) ? "AF_INET6" : "???", family); /* For an AF_INET* interface address, display the address */ if (family == AF_INET || family == AF_INET6) { s = getnameinfo(ifa->ifa_addr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if (s != 0) { printf("getnameinfo() failed: %s ", gai_strerror(s)); exit(EXIT_FAILURE); } printf(" address: <%s> ", host); } else if (family == AF_PACKET && ifa->ifa_data != NULL) { struct rtnl_link_stats *stats = ifa->ifa_data; printf(" tx_packets = %10u; rx_packets = %10u " " tx_bytes = %10u; rx_bytes = %10u ", stats->tx_packets, stats->rx_packets, stats->tx_bytes, stats->rx_bytes); } } freeifaddrs(ifaddr); exit(EXIT_SUCCESS); } SEE ALSO
bind(2), getsockname(2), socket(2), packet(7), ifconfig(8) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU
2017-09-15 GETIFADDRS(3)
All times are GMT -4. The time now is 07:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy