Hi ,
I have a set of files in a folder which i need to cut in to two parts....
Sample files
touch AE_JUNFOR_2014_MTD_2013-05-30-03-30-02.TXT
touch AE_JUNFOR_2014_YTD_2013-05-30-03-30-02.TXT
touch temp_AE_JUNFOR_2014_MTD_2013-05-30-03-30-02.TXT
touch AE_ACTUAL_2013_APR_MTD_2013-05-03-09-59-44.TXT
touch AE_ACTUAL_2013_APR_YTD_2013-05-03-09-59-44.TXT
touch temp_AE_ACTUAL_2013_APR_MTD_2013-05-03-09-59-44.TXT
I need the file name in the above files to be sent to two variables.
Only temp* files are considered for the cut.
Sample file :- "temp_AE_ACTUAL_2013_APR_MTD_2013-05-03-09-59-44.TXT"
var1 = AE_ACTUAL_2013_APR
var 2 = 2013-05-03-09-59-44.TXT
I tried the below but Cut takes in only one character as delmiter... I cannot use "M" in MTD as a delimiter because for March files the file name will have MAR before MTD and the result will be wrong.
echo temp_AE_ACTUAL_2013_APR_MTD_2013-05-03-09-59-44.TXT|cut -d "MTD" -f1
echo temp_AE_ACTUAL_2013_APR_MTD_2013-05-03-09-59-44.TXT|cut -d "MTD" -f2
Please help me to find a efficient way to cut the file names .
Thanks
Arun