Reputation: 23
I'm looking for a way to rename all these directories from:
1_20_10
1_20_20
1_20_30
1_20_40
to:
2_20_10
2_20_20
2_20_30
2_20_40
I tried this command:
mv /1_20*/ /2_20*/
and the rename command but doesn't work.
Upvotes: 0
Views: 33
Reputation: 1510
You can perform a substitution with sed
and iterate with a for
loop.
for i in 1_*; do
mv $i $(sed -En 's/^1_(.*)/2_\1/p' <<< $i);
done
Upvotes: 2