Can be done in a single one-liner:
ls *.sh | while read i; do mv "$i" "${i%.sh}.bash"; done
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?
Solution
Can be done in a single one-liner:
ls *.sh | while read i; do mv "$i" "${i%.sh}.bash"; done