Where:word1-word2-extension-serial1-serial2-name.cmt
word1: any length
word2: any length
extension: any length
serial1: 6 chars
serial2: 6 chars
name: any lengthSo, these name would be ok, for instance:
CONTAB1-PALAVRA2-NMT-123456-123456-gilberto.cmt
CTB1-PLV2-XYZ-654321-000001-joaozinho.cmtFrom those names, everything before the serials should be extracted. That is:
CONTAB1-PALAVRA2-NMT
CTB1-PLV2-XYZAt first, the nightmare are the 3 variable length parts and the NAME
So, the solution:
$ var='CONTAB1-PALAVRA2-NMT-123456-123456-gilberto.cmt'
$ echo ${var%%-??????-??????-*.cmt}
CONTAB1-PALAVRA2-NMTThe second example:
$ var='CTB1-PLV2-XYZ-654321-000001-joaozinho.cmt'
$ echo ${var%%-??????-??????-*.cmt}
CTB1-PLV2-XYZOnce again, the apparently cryptographic hieroglyphic SHELL did it!!!
:D
No comments:
Post a Comment