linux - Bash script to remove 'x' amount of characters the end of multiple filenames in a directory? -
i have list of file names in directory (/path/to/local). remove number of characters of filenames.
example filenames:
iso1111_plane001_00321.moc1 iso1111_plane002_00321.moc1 iso2222_plane001_00123.moc1 in every filename wish remove last 5 characters before file extension.
for example:
iso1111_plane001_.moc1 iso1111_plane002_.moc1 iso2222_plane001_.moc1 i believe can done using sed, cannot determine exact coding. like...
for filename in /path/to/local/*.moc1; mv $filname $(echo $filename | sed -e 's/.....^//'); done ...but not work. sorry if butchered sed options, not have experience it.
mv $filname $(echo $filename | sed -e 's/.....\.moc1$//'); or
echo ${filename%%?????.moc1}.moc1 %% bash internal operator...
Comments
Post a Comment