This question builds off of a previous question. I do not want to edit the previous question because then I would be introducing a new complexity to a question that already has SO many comments. It would skew the context of the current answers.
The following is the mapping file called mapping.txt
src/a/ tgt/aye/
src/b tgt/b/
src/c/ tgt/c
The source file structure is as follows
/tmp/testzone/src/a/afile.txt
/tmp/testzone/src/b/bfile.txt
/tmp/testzone/src/c/cfile.txt
First thing we do is create the target directory folder structure based on the mapping.txt
file
cut -f 2 mapping.txt | tr '\n' '\0' | xargs -0 mkdir -p
Which creates the target directory folder structure
/tmp/testzone/tgt/aye/
/tmp/testzone/tgt/b/
/tmp/testzone/tgt/c/
Next we run
xargs --arg-file mapping2.txt cp -a
Which seems to put the source directory contents into the target directory's c
directory. This is wrong. It should be using the mapping.txt
file to copy from source to target line by line.
/tmp/testzone/tgt/aye/
/tmp/testzone/tgt/b/
/tmp/testzone/tgt/c/a/afile.txt
/tmp/testzone/tgt/c/aye/
/tmp/testzone/tgt/c/b/bfile.txt
/tmp/testzone/tgt/c/c/cfile.txt
What could be causing this issue?