Question

Suppose I have some files in a dir called test_dir, like a.sh, b.sh, c.sh, d.bash, and so on. I need to change all the file *.sh to *.bash. How can I achieve it using shell?

Was it helpful?

Solution

Can be done in a single one-liner:

ls *.sh | while read i; do mv "$i" "${i%.sh}.bash"; done
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top