Skip to main content
added 199 characters in body
Source Link
deon
  • 11
  • 2

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?

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 and ends at the .csv. The filename could be any length.

NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619-10.csv_16062000352520'

The filenames respectively:

Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619-10.csv'

I use the following command to extract the filename from the notification filename but it only works for the second filename:

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?

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_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 = '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 if the 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?

added 396 characters in body
Source Link
deon
  • 11
  • 2

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 and ends at the .csv. The filename could be any length.

NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619-10.csv_16062000352520'

The filenames respectively:

Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619-10.csv'

I use the following command to extract the filename from the notification filename but it works only works for the second filefilename:

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? The first 4 strings will always be ignored

I receive notification files for different files.

NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619-10.csv_16062000352520'

The filenames respectively:

Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619-10.csv'

I use the following command but it works only for the second file:

echo $NotificationFile | cut -d "_" -f5-8

What is general command I can use for any filename length? The first 4 strings will always be ignored

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 and ends at the .csv. The filename could be any length.

NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619-10.csv_16062000352520'

The filenames respectively:

Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619-10.csv'

I use the following command to extract the filename from the notification filename but it only works for the second filename:

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?

added 38 characters in body
Source Link
deon
  • 11
  • 2

I receive notification files for different files.

NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619-10.csv_16062000352520'

The filenames respectively:

Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619-10.csv'

I use the following command but it works only for the second file:

echo $notificationFile$NotificationFile | cut -d "_" -f5-8

What is general command I can use for any filename length? The first 4 strings will always be ignored

I receive notification files for different files.

NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619-10.csv_16062000352520'

The filenames respectively:

Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619-10.csv'

I use the following command but it works only for the second file:

echo $notificationFile | cut -d "_" -f5-8

What is general command I can use for any filename length?

I receive notification files for different files.

NotificationFile = 'NFT_PPF_STANDARD_1720156B_NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv_16062000352520'
NotificationFile = 'NFT_PPF_IMPULSE_172555A_NBIRNans_Account_FFP_20160619-10.csv_16062000352520'

The filenames respectively:

Filename = 'NBIRNans_DFT_TILT_EOF_FFP_20160619-10.csv'
Filename = 'NBIRNans_Account_FFP_20160619-10.csv'

I use the following command but it works only for the second file:

echo $NotificationFile | cut -d "_" -f5-8

What is general command I can use for any filename length? The first 4 strings will always be ignored

edited body
Source Link
terdon
  • 252.2k
  • 69
  • 480
  • 718
Loading
Source Link
deon
  • 11
  • 2
Loading