I have a list file with names of files, i want read one file name from the list at a time and look for it under a directory structure with multiple sub folders and then once found move it into a diff folder.
Ex:
listfile.txt
Content of the file--
filename1.txt
filename2.txt
maindir
|--subdir1
|---subdir2/filename1.txt
|---subdir3/filename2.txt
read file names from listfile.txt one by one and move them to a diff folder say /destfolder.
Any suggestion would be great.
Thanks, Kavin
for file in
cat filelist.txt; do find $source_path -name "$file" -print0 | xargs -0 -I {} cp {} $archive_home ; done
– Kavin Palaniswamy Jun 29 '18 at 17:14cp
does not move the file, it copies it. – Kusalananda Jun 29 '18 at 18:02$source_path
and$archive_home
contained spaces, as these are unquoted. – Kusalananda Jun 29 '18 at 18:13