私がしたいことは:
src1=/path/to/source1
src2=/path/to/source2
dest1=/path/to/dest1
dest2=/path/to/dest2
loop
copy src(x) to dest(x) #here x=1,2,3..
break_loop
それでは、これをbashスクリプトでどのように実装しますか?
ベストアンサー1
バリアントとしてbashシェルがあるとします。
#!/bin/bash
declare -A dirs
dirs[/path/to/source1]=/path/to/dest1
dirs[/path/to/source2]=/path/to/dest2
for src in "${!dirs[@]}"
do
cp -- "$src"/* "${dirs[$src]}"/
done