I want to parse the file name and assign a variable (code) based on it. I think I can use cut to get each values. But can we do it in one command?
sample file name: 012345678_012345678-abcdefghijklmnop_YYYYMMDD_TTTT
from the 2nd qualifier 012345678 i need to assign a value to the variable (code).
if col-2 & col-3 is yy and col-4 & col-5 is 00 or 01 or 02 and col 678 is 'abc' assign code = usa
if col-2 & col-3 is yy and col-4 & col-5 is 00 or 01 or 02 and col 678 is not equal to 'abc' assign code = uk
if col-2 & col-3 is not equal to yy and col-4 & col-5 is not equal to 00 or 01 or 02 and col 678 is not equal to 'abc' assign code = Aus
Note: the 2nd qualifer is always after the first underscore and before the first dash. The yy is the value in the 2nd qualifier in position col -2 and col-3
Example file name:012345678_01yy00abc-xxxxxxxxxxxxxxxxxxxxx_20180408_1300 assign code = usa
Example file name: 012345678_01yy00xyz-xxxxxxxxxxxxxxxxxxxxx_20180408_1300 assign code = uk
Example file name: 012345678_01aa98def-xxxxxxxxxxxxxxxxxxxxx_20180408_1300 assign code = Aus (so if it not usa or uk, it is Aus)