04-02-2013
Please use code tags as required by forum rules!
One option, just dreamed up from the blue sky: Set up a counter, after the read, incremented by 0 until your grep matches. Then, increment by 1 and collect $line into the message file. When the counter hits 10, send the mail, reset increment to 0, clear the file, and continue.
Or, do the entire thing in e.g. awk.
BTW, you can take all the variable assignments out of the loop as it seems they remain constant.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
as the title, I had try use "wc -l test.txt" but it give me "<many spaces> 384 test.txt" but the result I want is just "384" could any person can help me that?
Thx:( (5 Replies)
Discussion started by: a8111978
5 Replies
2. Shell Programming and Scripting
If I have a file something like as shown below,
ARM*187878*hjhj
BAG*88778*jjjj
COD*7777*kkkk
BAG*87878*kjjhjk
DEF*65656*89989*khjkk
I need the line numbers to be added with a colon when it matches the string "BAG". Here in my case, I need something like
ARM*187878*hjhj... (4 Replies)
Discussion started by: Muthuraj K
4 Replies
3. Shell Programming and Scripting
Hi,
A very Good Evening to All,
I am writing a script for my application. I have a file with 1000 lines. Among that 1000 lines i am searching for a particular string. And from that string i need to pull all the data in to a seperate file.
For example the contents of my file is as below.
... (4 Replies)
Discussion started by: intiraju
4 Replies
4. Shell Programming and Scripting
Hi,
The below code will search a particular string(say false in this case) and return me 10 lines above and below the search string in a file.
" awk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print("***********************************");print;c=a;}b{r=$
0}' b=10 a=10 s="false" "
... (5 Replies)
Discussion started by: vimalm22
5 Replies
5. Shell Programming and Scripting
Hi Guys,
I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same.
can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies
6. Shell Programming and Scripting
i have one file, i am doing 'vi Filename' now i want to search for particular string and i want to know how many times that string occurs in whole file (5 Replies)
Discussion started by: sheelsadan
5 Replies
7. Shell Programming and Scripting
Hello,
I want to search 2 lines from the file. I wanted to display all such matches. Example file:
==================
Testfile is test
TEST1
TEST2
testing the file string
to do testing
TEST1
TEST2
sample strings
=================
I wanted to search the file with 2 lines
"
TEST1... (3 Replies)
Discussion started by: balareddy
3 Replies
8. Shell Programming and Scripting
i had requirement like i need to get "error" line of above 3 and below 3 from a file .I tried with the below script.But it's not working.
y='grep -n -i error /home/file.txt|cut -c1'
echo $y
head -$y /home/file.txt| tail -3 >tmp.txt
tail -$y /home/file.txt head -3 >>tmp.txt (4 Replies)
Discussion started by: bhas85
4 Replies
9. Shell Programming and Scripting
Hello
Take this file...
Test01
Ref test
Version 01
Test02
Ref test
Version 02
Test66
Ref test
Version 66
Test99
Ref test
Version 99
I want to substitute every occurrence of Test{2} with a unique random number, so for example, if I was using sed, substitution would be something... (1 Reply)
Discussion started by: funkman
1 Replies
LEARN ABOUT DEBIAN
rlm_counter
rlm_counter(5) FreeRADIUS Module rlm_counter(5)
NAME
rlm_counter - FreeRADIUS Module
DESCRIPTION
The rlm_counter module provides a general framework to allow access based on accumulated usage of a resource, such as total time online in
a given period, total data transferred in a given period, etc. This is very useful in a 'Prepaid Service' situation, where a user has paid
for a finite amount of usage and should not be allowed to use more than that service. Collection, monitoring, and replenishment of prepaid
services are beyond the scope of this module.
The main configuration items to be aware of are:
filename
The filename where the usage data is stored.
key An attribute which will be present in the Access-Request to be used as the 'index' value for the counter. A counter entry is tracked
for each unique key. The most likely key you will want to use is User-Name.
count-attribute
An attribute which will be used to increment the counter value. If this attribute is Acct-Session-Time or an integer value the
counter data is incremented by the Attribute value. For all other attribute types the counter is incremented by one.
reset How frequently the counter data should be set back to 0. Valid values for this variable are: hourly, daily, weekly, monthly, orn-
ever Alternatively, it can be user defined, in the form: num[hdwm]. num is a numeric value, followed by one or none of the follow-
ing letters. h: hours, d: days, w: weeks, m: months.
check-name
This defines an attribute name which will be registered by the counter module and can be used to set the maximum allowed value for
the counter after which the user is rejected. If Daily-Session-Time is set, you can use the following syntax in the Users file to
set a cap of 3600 seconds ( 8 hours ):
DEFAULT Max-Daily-Session := 3600
reply-name
This is the name of the attribute which will contain the remaining value for the counter in the reply packet when the user is suc-
cessfully authorized. The default attribute name is "Session-Timeout".
allowed-servicetype
This can be used to only apply the limitations to specific service types of sessions. For example, setting this to Framed-User will
only apply the counter module to Framed sessions, excluding other types such as Telnet or Rlogin.
cache-size
The maximum size of the cache to be used by the module. The default is 1000.
NOTES
This module registers an attribute, so it should be added to the instantiate section, to be called on server startup. When used in the
authorize section, it must come after any modules which set the 'check-name' attribute.
SECTIONS
instantiate, authorize, accounting
FILES
/etc/raddb/radiusd.conf
SEE ALSO
radiusd(8), radiusd.conf(5) rlm_sqlcounter(5)
AUTHOR
Chris Parker, cparker@segv.org
13 March 2004 rlm_counter(5)