I have these zip files:
PLP_633555_2015-03-04_01-12-01.zip PLP_634562_2004-03-02_02-15-07_UBIC.zip PLP_563462_2008-05-02_01-21-03_UBIC_STOC.zip
And I need each zip extracted into its appropriate directory with this format (basically, I only need the first 30 characters):
PLP_633555_2015-03-04_01-12-01 PLP_634562_2004-03-02_02-15-07 PLP_563462_2008-05-02_01-21-03
This is the command I currently have, which works but only for the second zip file (PLP_634562_2004-03-02_02-15-07_UBIC.zip)
for f in /PLP*.zip; do n=$(echo $f | cut -f 1-5 -d '_'); unzip -d $n $f;done
I would like to change it so that it reads only the first 30 characters of the zip file and then creates the directory based on that. It will ensure any new zip file naming format will work in the future.
I've tried changing the n variable part of the command to this
but that didn't work. I'm using Linux bash.