0

How to create a bash script to loop through some files and perform few actions that involves name alterations:

find all index.html files in all subdirectories except components/* and process each file like:

mv dir1/index.html dir1/index_dev.html
vulcanize -o dir1/index.html dir1/index_dev.html

mv dir2/index.html dir2/index_dev.html
vulcanize -o dir2/index.html dir2/index_dev.html
...

Thanks

1
  • you didn't even try to manually run your commands, if you were, you would have seen some 'file not found' error. Cause after doing mv index.html will not exist. Commented Jul 16, 2014 at 5:05

1 Answer 1

2

You can have:

for FILE in */index.html; do
    [[ $FILE == components/index.html ]] && continue  ## Skip.
    mv "$FILE" "${FILE%.html}"_dev.html
done
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.