Soldato
- Joined
- 22 Aug 2005
- Posts
- 8,968
- Location
- Clydebank
Hi all
I have this in a text file :
And would like to remove the " underscore part" i.e. BATCH040506_12 should be BATCH040506 etc.
I can do it but not with the last one that doesn't have a charater after.
Assume that there can be none or more than one charater after the underscore, and could be a letter or number.
This is what I have been trying so far:
Hmmm in trying to find the code I was using, that seems to actually work. Can anyone see any issue with that?
I have this in a text file :
Code:
abcdefghijkl abcdefghijk,BATCH040605_1,AB/2009/00123,username,05 Jun 2009
abcdefghijkl abcdefghijk,BATCH040605_2,AB/2009/00123,username,05 Jun 2009
abcdefghijkl abcdefghijk,BATCH040605_11,AB/2009/00123,username,05 Jun 2009
abcdefghijkl abcdefghijk,BATCH040605_12,AB/2009/00123,username,05 Jun 2009
abcdefghijkl abcdefghijk,BATCH040605_,AB/2009/00123,username,05 Jun 2009
And would like to remove the " underscore part" i.e. BATCH040506_12 should be BATCH040506 etc.
I can do it but not with the last one that doesn't have a charater after.
Assume that there can be none or more than one charater after the underscore, and could be a letter or number.
This is what I have been trying so far:
Code:
cat OUT.TXT | grep _ | sed -e "s/_[0-9A-Z]*//g"
Hmmm in trying to find the code I was using, that seems to actually work. Can anyone see any issue with that?