Script content:
Copy Code code as follows:
#!/bin/bash
For IP in ' cat ip.lst '
Todo
./ssh.exp $ip >/dev/null 2&>1
Done
nk= ' awk ' begin{bs=4000000}/access/{if ($1>bs) {Nk=nr-1;print nk}} ' Exp.log '
For NNK in $NK
Todo
Awk-f "[@| ']" ' nr== ' "$nnk" ' {print $} ' Exp.log
Done
And then found the $ ghost in awk. So it's further simplified into this:
Copy Code code as follows:
#!/bin/bash
For IP in
' Cat Ip.lst '
Todo
./ssh.exp $ip >/dev/null 2&>1
Done
awk ' Begin{bs=4000000}/access/{if ($1>bs) print x}; {x=$0} ' exp.log|awk-f ' [@| '] ' {print $} '
Finally a round of their own with a word to fix its dream. Yeah~ But the principle is still not very clear. Because print x;x=$0 is the previous line, print $ is the bank. Why? Online to print the previous line also put forward another writing, it is more puzzling to see:
awk '/regex/{print (x== "" "": x)}; {x=$0} ' $
And the following line is printed:
awk '/regex/{getline;print} ' $
But this is exactly the right up and down line, if it is to the first few lines, or to rely on NR operation.
Because of the streaming processing of awk, print x;x=$0, this time X will not print until the next line.