I need a script which should watch a directory for a file with specific directory.
If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column.
The file should be moved to another directory and the a mail should be sent to list of email id's and email body should contain the strings which have been trimmed.
For example, I have a file GEFCO_INVRPTB9PDB_VIB1.351.egs. The script should look for lines starting with CSG2 and ARD1. If it starts with CSG2,Script should copy data between position 5-20 and put it into the body of email.
Also, the original file should be moved to another directory.
UNB10941A780843653 0941A081195390TEST 10000006 140603 2300 GEFCO-SALCEDA 25843
UNH1INVRPTSH 140603 2300 25843 20
MID1VIB1540 20140603 2224
NAD1SDT 0060183727804 28734G 16 VISTEON SISTEMAS INTERIORES EL CERQUIDO S/N 36472 SALCEDA DE CASELAS ES CARLOS MARQUES 986343402 986346252 28734G 10
NAD1CDT 0941A780843654 VIGO GEFCO CTL1 CTL GEFCO ESPANA AVENIDA CITROEN, S/N ZONA FRANCA 36210 VIGO ES JOSE BRION 986214434 986212363 5
CSG1006046200400300000 PEUGEOT CITROEN AUTOMOBILES AVENIDA CITROEN 36210 VIGO ES
CSG2FV6VFF
ARD196738649ES 1 20140602 2255 18 PCE VIB1540 00000000 925064500ES 1 1 2 2X 006046200400300000 PEUGEOT CITROEN AUTOMOBILES AVENIDA CITROEN 36210 VIGO ES 0060183727804 VISTEON SISTEMAS INTERIORES EL CERQUIDO S/N 36472 SALCEDA DE CASELAS ES 0060183727804 VISTEON SISTEMAS INTERIORES EL CERQUIDO S/N 36472 SALCEDA DE CASELAS ES 0060183727804 VISTEON SISTEMAS INTERIORES EL CERQUIDO S/N 36472 SALCEDA DE CASELAS ES 20140602 2255 VIB1540 1 1 1 04760 04760 1 PCE