a_files=(/path/to/files/*.csv)
b_files=(/path/to/files/*.csv)
out_dir="/path/to/output/folder"
# create the output directory
mkdir -p "$out_dir"
for ((i=0; i<"${#a_files[@]}"; i++)); do
# move the output to "$out_dir" with the filename the same as in ${a_files[i]}
paste -d, <(cut "${a_files[i]}" -d, -f1-6) <(cut "${b_files[i]}" -d, -f7-) \
> "$out_dir"/"$(basename "${a_files[i]}")"
done
但我觉得这对xargs来说就像一份工作,但那只是我:
a_path="/path/to/files/*.csv"
b_path="/path/to/files/*.csv"
out_dir="/path/to/output/folder"
join -z <(printf "%s\0" $a_path) <(printf "%s\0" $b_path) | xargs -0 -n2 sh -c 'paste -d, <(cut "$1" -d, -f1-6) <(cut "$2" -d, -f7-) > '"$out_dir"'/"$(basename "$1")"' --