Reputation: 9036
I have the following list:
faultsPackage1
faultsPackage2
faultsPackage3
faultsPackage4
faultsPackage5
faultsPackage6
faultsPackage7
seafloor
topLowerMiocene
topMetamorphicBasement
topMiddleEocene
topMiddleMiocene
topMiddleOligocenetoUpperEocene?
topPlioceneFromODP684
topUpperMioceneFromODP684
but I need to shape those rows like this (specifically change only those "faultsPackage"):
faultsPackage
faultsPackage
faultsPackage
faultsPackage
faultsPackage
faultsPackage
faultsPackage
seafloor
topLowerMiocene
topMetamorphicBasement
topMiddleEocene
topMiddleMiocene
topMiddleOligocenetoUpperEocene?
topPlioceneFromODP684
topUpperMioceneFromODP684
because these names represent variables, and these variables will pop up some further processes. I tried:
sed 's/[1-7]//'
but it deletes all numbers in the list, so it's not useful. I was thinking that, for instance, in somehow it could only be detected the letter "e" followed by numbers from 1-7 and then delete those numbers, but not sure how to implement that in shell.
Any hint will be appreciated, thanks in advance.
Upvotes: 2
Views: 47
Reputation: 784938
This sed should work:
sed -i.bak 's/\(faultsPackage\)[0-9]*/\1/' file
This regex finds all lines with faultsPackage<number>
text and replaces it with just faultsPackage
using captured group #1
Upvotes: 2