I have more than hundred directories named SP_[number]_date. I'd like to rename all to just SP_[number].
I can only figure out how to do that by mv SP_1_date SP_1 but that will take ages. Can I rename all at once? I thought that I could do something like for num in ./*; do mv SP_$num_date SP_$num; done but it doesn't do the trick.
renameexpression would bes/_date$//– muru Aug 10 '15 at 07:20dateliteral or is a date, like inSP_1_May 12, 2015? – Rmano Aug 10 '15 at 10:50mv SP_$num_date SP_$numdidn't work was that you don't have a variable$num_date(or, at least, that's one of the reasons). You would have needed${num}_dateto separate the variable$numfrom a constant suffix_date. Another problem is that the value in$nummight be./SP_1_dateso themvcommand was attempting to moveSP_./(since$num_datewas undefined and hence an empty string) toSP_./SP_1_date. – Jonathan Leffler Aug 10 '15 at 14:30