0

Hi i came across an issue,

So i have 500 CSV files with generic name like file_1.csv file_2.csv ..... file_500.csv and i have 500 empty directories that i created in same location with names like directory_1 directory_2 .... directory_500. All the 500 files and 500 directories are in the same location, i want to move each file into each directory of their matching sequence, something like this,

move file_1.csv to directory_1
move file_2.csv to directory_2
move file_3.csv to directory_3
.
.
.
move file_500.csv to directory_500

So, how do i do it? can someone let me know please.

1
for i in {1..500}
do
  mv file_${i}.csv directory_${i}/
done
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.