I have a simple list like following
ss_Asd_n1_455_9_1
ss_Asd_n1_98_9_32
ss_Asd_n1_562_9_145
ss_Asd_n1_1_9_6
Using regex linux I want the list to trimmed like follwing
ss_Asd_n1_455_9
ss_Asd_n1_98_9
ss_Asd_n1_562_9
ss_Asd_n1_1_9
I tried the following code but it did not print any output
grep '[a-z_]*[a-zA-Z]+(\_)[v0-9]+(\_)[0-9]+(\_)[0-9]'
Kindly guide me. Thanks in advance
grepif you need to modify the lines? Usesed -i.bak 's/\(.*\)_[^_]*$/\1/' filesed -i.bak 's/_[0-9]*$//' file. Do you really need to check the format that thoroughly?