Can I use bash brace expansion in for loop?
Solution 1:
Prepare two arrays:
src=( bad\ name{1..4} )
dst=( anothername{a..d} )
Confirm there are 4 elements in each:
echo "${#src[@]}"
echo "${#dst[@]}"
Then in dir2
:
for i in {0..3}; do mv "${src[i]}" "../${dst[i]}"; done
Indexed arrays are indexed from 0
, that's why {0..3}
, not {1..4}
in the loop.