Hello PHV,
I have been using your solution for a while and it worked OK until I got to different problem. Here is a list:
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Next Directory/Pending/P0I5002_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Next Directory/PendAppr/P0I5003_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Next Directory/Review/P0I5004_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Direct Lending/Pending/P0I5006_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Direct Lending/PendAppr/P0I5007_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Direct Lending/Review/P0I5008_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Canada/PendAppr/P0I5011_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Canada/Review/P0I5012_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/HHoldDirect/Pending/P0J01A10_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/HHoldDirect/PendAppr/P0J01A11_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/HHoldDirect/Review/P0J01A12_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/US/PendAppr/P0J01A3_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/US/Review/P0J01A4_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/Approved/P0J01A5_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/Pending/P0J01A6_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/PendAppr/P0J01A7_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/Review/P0J01A8_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Control/Rescission/PendFundSwChg/Daily/P0K7201PFSC_03-25-2004.roi
I have to extract 8 bytes long vs. 7 bytes long pattern in some cases.
After executing slightly modified your original command:
sed -n 's!.*/\(P......*\)_.*!\1.txt!p'
I receive the following result:
P0I5002.txt
P0I5003.txt
P0I5004.txt
P0I5006.txt
P0I5007.txt
P0I5008.txt
P0I5011.txt
P0I5012.txt
P0J01A10.txt
P0J01A11.txt
P0J01A12.txt
P0J01A3.txt
P0J01A4.txt
P0J01A5.txt
P0J01A6.txt
P0J01A7.txt
P0J01A8.txt
P0K7201PFSC.txt
As you can see I can got extra 4 alpha characters in the last record.
How can I modify above command to extract P0K7201.txt instead?
I appreciate for your help!
Thanks again.
Alex.
I have been using your solution for a while and it worked OK until I got to different problem. Here is a list:
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Next Directory/Pending/P0I5002_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Next Directory/PendAppr/P0I5003_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Next Directory/Review/P0I5004_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Direct Lending/Pending/P0I5006_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Direct Lending/PendAppr/P0I5007_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Direct Lending/Review/P0I5008_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Canada/PendAppr/P0I5011_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Pricing Matrices/Canada/Review/P0I5012_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/HHoldDirect/Pending/P0J01A10_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/HHoldDirect/PendAppr/P0J01A11_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/HHoldDirect/Review/P0J01A12_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/US/PendAppr/P0J01A3_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/US/Review/P0J01A4_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/Approved/P0J01A5_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/Pending/P0J01A6_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/PendAppr/P0J01A7_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/SpecialRules/Canada/Review/P0J01A8_03-25-2004.roi
/Folder1/Next Directory/Operational/Pricing/Control/Rescission/PendFundSwChg/Daily/P0K7201PFSC_03-25-2004.roi
I have to extract 8 bytes long vs. 7 bytes long pattern in some cases.
After executing slightly modified your original command:
sed -n 's!.*/\(P......*\)_.*!\1.txt!p'
I receive the following result:
P0I5002.txt
P0I5003.txt
P0I5004.txt
P0I5006.txt
P0I5007.txt
P0I5008.txt
P0I5011.txt
P0I5012.txt
P0J01A10.txt
P0J01A11.txt
P0J01A12.txt
P0J01A3.txt
P0J01A4.txt
P0J01A5.txt
P0J01A6.txt
P0J01A7.txt
P0J01A8.txt
P0K7201PFSC.txt
As you can see I can got extra 4 alpha characters in the last record.
How can I modify above command to extract P0K7201.txt instead?
I appreciate for your help!
Thanks again.
Alex.