Entering edit mode
2.9 years ago
Jecy J
•
0
Hi everyone,
i have done spades assembly of multiple samples and would like to copy all the contig file from subdirectory.
I tried like this
cat file_list.txt | xargs -I {} cp {} /destination/dir/path
# file_list.txt : all the contig file name
But somehow its showing the contig file not present in subdirectory, but I crossed check and found files are present.
Can anybody please let me the solution. I am using macOS.
Thanks JC
I think this should work:
Sorry it did not work
1st try
2nd try.
can you post one or two lines from
abc.txt
? I think xargs is not getting any input. Btw, are you using windows or gnu-linux?The subdirectory like this :
Then your command should be like this:
Assuming that all files in
abc.txt
are intest1
directory.Thanks for reply. Sorry, directory structure are like this.
and i would like to copy files present inside the subdirectories to test directory
xargs
must be supplied exact location to copy the files. Since it is not happening,xargs
is failing. Eitherabc.txt
should have file name with path or you supply file path toxargs
. You can take a different approach as follows:It would have been better if you furnished
tree
at the start. If you usefind
, you don't even needxargs
.Always post the error please . The function you posted worked on my system. Check for the typos, incorrect destination name and check if directory names have special characters such as space etc.
You can do this in several ways.
cat test.txt| while read line; do echo cp $line /destination/dir/path; done
(Remove echo after checking the dry-run)cat test.txt| parallel --plus --dry-run cp {} $line /destination/dir/path
(Remove --dry-run after checking the dry-run)Parallel comes from GNU-Parallel and is present in system repos for most of the gnu-linux distros.