Copy the files in the bill folder to the bill1 and bill2 folders according to certain rules (file name parity.
Update the progress tag of bill1 and bill2 (Update file. max)
File3 is the label of the latest file under the bill directory. It is updated every minute under normal circumstances (Format: 20121016122100)
Copy codeThe Code is as follows :#! /Bin/bash
# For wanggy 2012/10/16
Bill1 =/infosms/bill1
Bill2 =/infosms/bill2
File_max = 'cat file3'
Cd/infosms/bill
While:
Echo "start"
Do
If [$ file_max! = 'Cat file3']; then
Echo "not equal, processing"
# Determine file3 11-12 bits (parity)
Num1 = 'cut-c 11-12 file3'
# If 10 is not added #08 is encountered when the modulo is obtained, an error occurs. (Octal judgment ?)
Num = $(10 # $ num1 % 2 ))
# Num = $ ($ num1 % 2 ))
# Obtain the current file under bill (latest)
File_name = B 'cat file3'
Echo "latest file: $ file_name"
Case $ num in
1)
Echo "odd"
Cp-a $ file_name ../bill1
Echo 'cat file3'> ../bill1/file. max
0)
Echo "even"
Cp-a $ file_name ../bill2
Echo 'cat file3'> ../bill2/file. max
Esac
Echo "returns the latest value to file_max"
File_max = 'cat file3'
Else
Echo "equal, not processed, quit! "
# File_date = 'cat $ filename'
# Exit 1
Fi
Echo "wait 10 seconds, next time judge ..."
Sleep 10
Done