Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a set of files that are named in the vein of "some_file-nameN", where N is a number starting at 1, incrementing, and ending somewhere between 10 and 30. I now need to insert a file at the start. How can I increment the number of the file using ZMV and ZSH?

share|improve this question
add comment

1 Answer

Starting from the directory containing the files, and assuming the range is 1 to 30:

for n in {30..1};
mv some_file-name$n some_file-name$(( $n+1 ))
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.