The AAA. Log content of the file to be processed:
09/26 00:00:08 116.41834259033203 39.90071597768346 116.60888671875 35.38904996691167
09/26 00:01:34 121.13089397549632 30.98941357306606 121.55966117978099 31.149880293437714
09/26 00:01:51 117.12383329868318 39.243494180634734 117.12383329868318 39.243494180634734 0
09/26 00:03:55 117.12383329868318 39.243494180634734 117.12383329868318 39.243494180634734 0
09/26 00:04:07 106.70314550399783 26.556866721950268 106.72096878290178 26.58711559252519
09/26 00:05:23 117.12383329868318 39.243494180634734 117.12383329868318 39.243494180634734 0
09/26 00:05:38 114.18694585561754 36.686433818538205 115.66599234938623 37.7350984521996
09/26 00:05:57 121.13089397549632 30.98941357306606 121.55966117978099 31.149880293437714
Handling requirements:
The last column is less than lines, and the content of the third to sixth columns is saved to another file, bbb.txt.
Shell script program:
#! /Bin/bash
Echo ''> bbb.txt
While read line # Read the file "/bak/log/aaalog" line by line"
Do
Distance = $ (echo "$ line" | awk-F' \ t'' {print $7} ') # retrieves the seventh column of each row and assigns the value to distance. Syntax: temp = $ (Value assignment content) or temp = 'value assignment content'. Note that it is not a single or double quotation mark.
# If [[$ distance <3000]; then
# Echo "$ line" | awk-F' \ t'' {print $3, $4, $5, $6} '> bbb.txt
# Fi
[$ Distance <50000] & Echo "$ line" | awk-F' \ t' {print $3, $4, $5, $6} '> bbb.txt extract the seven rows smaller than and specify the output columns to the bbb.txt file.
Done </bak/log/aaalog
# Note:
# Condition comparison Syntax: If [comparison condition]; then... Fi
# Or: [comparison conditions] & what to do.