I receive notification files for different files. I want to extract the filename from these notification files which I would use in another process. The first 4 strings of the notification file will always be ignored. So the filename starts at the 5 position, can start with any character and ends at the .csv. The filename could be any length.
An example:
NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619'NFT_PPF_IMPULSE_172555A_Acc_Account_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_CRI_Position_FFP_20160619-10.csv_16062000352520'
The filenames respectively:
Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619'Acc_Account_FFP_20160619-10.csv'
Filename = 'CRI_Position_FFP_20160619-10.csv'
I use the following command to extract the filename from the notification filename but it only works forif the second filename contains only 3 '_'s:
Extract = echo $NotificationFile | cut -d "_" -f5-8
# $NotificationFile is the NotificationFile above
# Extract should be equal to Filename
What is a general command I can use for any filename length?