I have files in some path. Say when i do ls -lrt
, i get
20160401_RM_ARN_MAPPING-M_RTL_NORTH_DELH_101.csv
20160401_RM_ARN_MAPPING-M_RTL_NORTH_DELH_102.csv
20160401_RM_ARN_MAPPING-M_BND_NORTH_DELH_102.csv
20160405_RM_ARN_MAPPING-M_RTL_NORTH_DELH_101.csv
20160405_RM_ARN_MAPPING-M_RTL_NORTH_DELH_102.csv
20160401_MAP_RTL_BANK-M_RTL_NORTH_DELH_101.csv
20150401_RM_ARN_MAPPING-M_RTL_NORTH_DELH_101.csv
I want the distinct file names after the date and before the "-" delimiter.
I tried
ls -lrt | awk '{print $9}' | sed '1d' | awk -F'-' '{print $1}'
It gives
20160401_RM_ARN_MAPPING
20160401_RM_ARN_MAPPING
20160401_RM_ARN_MAPPING
20160405_RM_ARN_MAPPING
20160405_RM_ARN_MAPPING
20160401_MAP_RTL_BANK
20150401_RM_ARN_MAPPING
But I want only
RM_ARN_MAPPING
MAP_RTL_BANK
as output, i.e distinct names after removing the date. Here the first 8 characters are fixed and it will be YYYYMMDD format.