Got it.
$1!=0&&$2==0{ b[$3]-=$4;}
$1==0&&$2==0{ b[$3]+=$4;}
$1==0&&$2!=0{ b[$3]-=$4;print $3, b[$3] }
It works for this particular case.
I am still looking for alternative solutions.
Thanks.
I could use that approach.
The blocks are not necessarily 9 lines. It could change from one block to another. My bad I did not specify that. Still I believe I can use your approach . Will post back as soon as I get some solution.
I have four columns input data.x,y,z b,c,d are some numbers not necessarily the same.
x 0 z1 bl
x 0 z2 cl
x 0 z3 dl
0 0 z1 bc
0 0 z2 cc
0 0 z3 dc
0 y z1 br
0 y z2 br
0 y z3 br
The data could be separated in blocks of triplets for which the third column is the same.
The sequence z1,z2,z3 would...
Hope I am not deviating much from the thread promp
Recently I had to setup a cronjob where periodically would copy the file over scp.The command portion of my cronttab looked something like that.
/usr/bin/scp -i /home/user/.ssh/id_dsa /tmp/file.dat server.net:~/
If I were to execute the same...
Thanks again feherke.
The deisired output for regex1 regex2 would be
1 11 12
2 21 22
3 31 32
To explain.
First value of each row is the block number.
Values two three are the values of the fields right under the regex1 and regex2.
Thanks.
My initial try was this.
awk '{for(i=1;i<=NF;++i)if(match($i,/regex1/)); getline; print $i }'
What I don't understand is why the /regex1/ outside the {...} block is needed.
If you remove it awk should process that for loop inside the {...} for each line of the input file and yet if I...
simple example inputfile
regex1 regex2 regex3
1 2 3
4 5 6
regex1 regex3 regex2
aa bb cc
7 8 9
If I want to print the next line after the regex2.
In my inptut file
awk '/regex1/{getline;print $0}' inputfile
How can I print only the...
try denyhosts
http://denyhosts.sourceforge.net/
Adds ip's to //etc/hosts.deny after X number of unsuccessful login attempts for the period of the last Y days.
Highly configurable with many options.
or
sshutout
Blocks ip's on the iptables level...
Consider the input file where the last $2==y entries are consecutive.
1 y 10
2 y 11
3 y 10
4 n 12
5 n 22
6 y 12
7 y 12
8 n 33
9 y 12
10 y 10
11 y 10
12 y 10
13 y 10
14 n 12
Now the output of the the second code will give
1
2
3
6 - 7
9
10
The last line is missing...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.