Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to add leading zeros to my file names using Bash (Shell) so they get renamed from rock0.py .. rock500.py to rock000.py ... rock500.py.

I want to add leading zeros to my file names using Bash (Shell) so they get renamed from rock0.py .. rock500.py to rock000.py ... rock500.py. Please tell me why the following code is not working:

for file in rock*.py; do mv "$file" "rock$(printf "%03d" ${file#rock}).py" done

Please let me know if I am making a spacing error or anything as I am super new to Bash, so I have no idea why my file names are not changing to add leading zeros at the start. If you have a different code that might work, feel free to share! Thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

Students also viewed these Databases questions

Question

Define Management by exception

Answered: 1 week ago

Question

Explain the importance of staffing in business organisations

Answered: 1 week ago

Question

What are the types of forms of communication ?

Answered: 1 week ago

Question

D How will your group react to this revelation?

Answered: 1 week ago