Sponsored Content
Top Forums Shell Programming and Scripting How find lines, export sum into file? Post 303045674 by nimafire on Wednesday 8th of April 2020 03:48:13 AM
Old 04-08-2020
i appreciate your help.
output still 0,
ive trace the code:

[root@srv ~]# bash -x script.sh
+ LOG=/var/log/scan.log
+ TOTAL=0
+ grep Virus /var/log/scan.log
+ read _ _ NUM
+ TOTAL=4
+ read _ _ NUM
+ TOTAL=9
+ read _ _ NUM
+ TOTAL=9
+ read _ _ NUM
+ echo 0
0
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to get the sum of all the lines in the file

Hi I have the following file, how I will calculate the sum of all the entries in the file. > cat abc 2 3 4 now the sum should be 2+3+4 = 9 (4 Replies)
Discussion started by: sdosanjh
4 Replies

2. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

3. Shell Programming and Scripting

Sum of all lines in file without roundup with awk

Hi, I have a file and I want to sum all the numbers in it. Example of the file: 0.6714359 -3842.59553830551 I used your forum (https://www.unix.com/shell-programming-scripting/74293-how-get-sum-all-lines-file.html) and found a script, what worked for me: awk '{a+=$0}END{print a}'... (8 Replies)
Discussion started by: mario8eren
8 Replies

4. Shell Programming and Scripting

find string(s) in text file and nearby data, export to list help

Hi, So I'm kinda new to shell scripts and the like. I've picked up quite a bit of use from browsing the forums here but ran into a new one that I can't seem to find an answer for. I'm looking to parse/find a string AND the next 15 or so charachters that follow the string within a text file... (1 Reply)
Discussion started by: kar23me
1 Replies

5. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

6. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum

Hi friends, This is sed & awk type question. It is slightly different from my previous question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers (but no more than 10 numbers in series) whenever i find it and produce an output file with the... (4 Replies)
Discussion started by: kaaliakahn
4 Replies

7. UNIX for Dummies Questions & Answers

How to export some lines from a file to a new file?

Dear everyone, I have a big file with many information in it, but I just want some lines. I don't know exactly what the number of the line I want, I only know some part of these line. It all starts with the word 'F(tot :1 )' I use grep command and find it. It looks like that on the screen:... (3 Replies)
Discussion started by: phamnu
3 Replies

8. Shell Programming and Scripting

How to find sum of any 'n' number of values from file matching target value?

I have a simple text file having payment amount value on each line. At the end of day 'n' number of payments created difference in amount that I need to match from this file. I have information about how many payments created difference and difference amount. Please help me to build shell... (3 Replies)
Discussion started by: swats007
3 Replies

9. Shell Programming and Scripting

Sum product of even/odd lines

Hi, I have a text file like this 6.0000E-02 0.00000E+00 0.0000 0.00000E+00 0.0000 7.0000E-02 5.00000E-10 1.0000 5.00000E-10 1.0000 8.0000E-02 3.00000E-09 0.4082 3.00000E-09 0.4082 9.0000E-02 3.50000E-09 0.3780 3.50000E-09 0.3780 1.0000E-01 1.00000E-09... (2 Replies)
Discussion started by: f_o_555
2 Replies

10. Shell Programming and Scripting

Find all lines in file such that each word on that line appears in at least n lines of the file

I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies
IPFM.CONF(5)							File Formats Manual						      IPFM.CONF(5)

NAME
ipfm.conf - IP Flow Meter configuration file DESCRIPTION
ipfm.conf is ipfm(8) configuration file. A hash mark (``#'') indicates that the end of the line is a comment and it will be ignored. The configuration rules will be interpreted from the end, and the first matching rule will be used, unless specified here. IPFM uses local and global variables, so it can manage multiple logs (different time delay, different hosts, different log filename ...) at the same time. Global variables will be used for all logs and local variables will only be used in the log being defined. GLOBAL VARIABLES
NETWORK DEVICE Syntax : DEVICE <device-name> <device-name> is the device on witch ipfm will log packets. IPFM monitors only one device. Time Coordinates Syntax : [UTC|local] This decides if IPFM will use UTC or local time in its outputs (log filename and the timestamp inside the file). Default is local. Note that IPFM works internally with UTC, and that the dates entered in the config file are UTC (see AFTER Syntax). NEW LOG Syntax : NEWLOG This creates a new log entry, where you can define new local variables. LOCAL VARIABLES
HOSTS TO LOG ipfm logs only specified hosts. Syntax: LOG [[NONE|FROM|TO|BOTH] <host>] [[NOT] WITH <host>] NONE do not log anything from or to this <host> FROM do log packets from this <host> TO do log packets to this <host> BOTH (default) do log packets from and to this <host> <host> can be : x.x.x.x : an IP. x.x.x.x/x.x.x.x : an IP followed by a subnet mask. WITH specifies if the packet is ignored (NOT WITH) or logged (WITH), in function of the second IP present in the packet. Examples : LOG 10.10.10.0/255.255.255.0 NOT WITH 10.10.10.1 will log any packets from or to hosts in subnet 10.10.10.0/255.255.255.0, except packets involving host 10.10.10.1 . LOG WITH 10.10.10.23 will log any packets in relation with host 10.10.10.23 LOG will log everything. OUTPUT TIME DELAY ipfm outputs its statistics every fixed period, with the ability to fix an exact time origin and offset, in Coordinated Universal Time (UTC). Syntax: DUMP EVERY <time> [AFTER <time>] <time> is composed of : <number> second(s) <number> minute(s) <number> hour(s) <number> day(s) Default DUMP time is 24 hours Default AFTER time is 0 seconds Examples: DUMP EVERY 30 minutes will dump the stats every 30 minutes at x:00 and x:30. DUMP EVERY 1 hour AFTER 7 minutes will dump the stats every hour, at 0:07, 1:07, 2:07, and so on, regardless of the time at which ipfm was launched. DUMP EVERY 1 day AFTER 14 hours will dump data every day, at 14:00:00 UTC (for France localtime (during the summer), at 16:00:00 +0200) CLEARING STATS You may want to clear your statistics sometimes, or after each dump. Syntax : CLEAR [ ALWAYS | NEVER | EVERY <time> [AFTER <time>] ] <time> is composed of : <number> second(s) <number> minute(s) <number> hour(s) <number> day(s) Default CLEAR mode is ALWAYS. Default AFTER time is 0 seconds. Note that both time values MUST be a multiple of the DUMP delay. Also, this line MUST come after the DUMP line. Examples CLEAR ALWAYS will clear the stats after every DUMP. CLEAR NEVER will never clear the stats, which means you are doing incremental statistics. CLEAR EVERY 30 minutes will clear the stats every 30 minutes at x:00 and x:30. Note that if your DUMP line had an AFTER value such as 3 minutes, this rule will clear the stats at x:03 and x:33. CLEAR EVERY 1 hour AFTER 10 minutes will clear the stats every hour, at 0:10, 1:10, 2:10, and so on. Note that if your DUMP line had an AFTER value such as 3 minutes, this rule will clear the stats at 0:13, 1:13, 2:13 and so on. LOG FILENAME Every delay, ipfm writes its output into a file, which name is specified by the rule FILENAME Syntax: FILENAME <filemask> <filemask> is a quoted string (eg. "/path/to/filename") that is parsed using strftime(3) syntax. Default FILENAME is /var/log/ipfm/%d-%b.%H-%M NOTE : The file will be overwritten without any check. REVERSE DNS You can activate or deactivate reverse DNS in the output file. WARNING : activating reverse DNS can delay a lot the production of the log file, due to DNS timeouts. Syntax : [RESOLVE|NORESOLVE] Default is NORESOLVE SORT OUTPUT FILE ipfm can sort output file depending on IN, OUT or TOTAL. Syntax : SORT IN|OUT|TOTAL Default is to sort nothing. Please note that this option could delay a bit the production of the log file. SET PROMISCUOUS MODE You can choose to log all packets on the network (default) or only packets which destination is your network device. This option could also be useful if you wish to set the promiscuous mode yourself (ifconfig eth0 [-]promisc), as the promisc mode is very badly handled under Linux. Please note that under Linux, if you run a program that sets the promiscuous mode (for example tcpdump), ipfm will also see its network interface set into promiscuous mode. Syntax [NO]PROMISC Default is PROMISC APPEND OR REPLACE LOG FILES You can choose to append the output to an existing logfile or to replace the old file by a new one. Syntax : APPEND|REPLACE Default is REPLACE SEE ALSO
strftime(3), ipfm(8) AUTHORS
Robert CHERAMY <tibob@via.ecp.fr> Andres KRAPF <dae@via.ecp.fr> Last change: 26 October 2000 IPFM.CONF(5)
All times are GMT -4. The time now is 11:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy