I have about 100 files.
They are named like this.
3000_ABCD_XXXXXXX.csv
3000_ABCD_YYYYYYY.csv
3000_ABCD_XYXYZYZ.csv
3000_EFGH_XXXXXXX.csv
3000_EFGH_YYYYYYY.csv
3000_EFGH_XYXYZYZ.csv
3000_IJKL_XXXXXXX.csv
3000_IJKL_YYYYYYY.csv
3000_IJKL_XYXYZYZ.csv
Currently I'm zipping each file individually but I want to group them based on their common substring like for example ABCD.zip
will store
3000_ABCD_XXXXXXX.csv
3000_ABCD_YYYYYYY.csv
3000_ABCD_XYXYZYZ.csv
EFGH.zip
will store
3000_EFGH_XXXXXXX.csv
3000_EFGH_YYYYYYY.csv
3000_EFGH_XYXYZYZ.csv
etc.
I'm very new to Unix/Bash scripting. Could anyone point me in the right direction?
Edit: ABCD
,EFGH
,IJKL
are not known in advance. Their position and width within the file name is guaranteed, though.