0
I'm trying to figure out how to copy a list of files to a list of subdirectories.
eg. I have 300 files to copy into 300 subdirectories - 1 to 1.
file1 -> dir1/sub
file2 -> dir2/sub
file3 -> dir3/sub
file4 -> dir4/sub
.
.
file300 -> dir/sub300
I normally have the files in the current directory where the directories are located so i would run something like
find . -type f -name "file*"
copy to
find . -type d -name "dir*/sub"
What would be the best way to run such a script? Thanks.
1To make people feel better about the variable expansion, use
file${i} dir${i}/sub
. Oh, omitting the curly braces will work fine. But the curly braces are a good habit if you're going to be adding things on the end of variables, whether or not the addition includes delimiters like slashes. – bgStack15 – 2014-09-24T16:24:47.667In general I agree. – jimmij – 2014-09-24T16:29:29.673