Skip to main content
added 138 characters in body
Source Link
Zombo
  • 1
  • 69
  • 414
  • 436

Make it unique in the process. But this require sorting:

find "$HOME" -name '*.txt' -type f -print0 | sort -zu | xargs -0 cp -t "$HOME/newdir" 

Or if it's not about the generated files, try to use the -u-u option of cpcp.

find "$HOME" -name '*.txt' -type f -print0 | xargs -0 cp -ut "$HOME/newdir" 
 -u copy only when the SOURCE file is newer than the destination file or when the destination file is missing 

Make it unique in the process. But this require sorting:

find "$HOME" -name '*.txt' -type f -print0 | sort -zu | xargs -0 cp -t "$HOME/newdir" 

Or if it's not about the generated files, try to use the -u option of cp.

find "$HOME" -name '*.txt' -type f -print0 | xargs -0 cp -ut "$HOME/newdir" 

Make it unique in the process. But this require sorting

find "$HOME" -name '*.txt' -type f -print0 | sort -zu | xargs -0 cp -t "$HOME/newdir" 

Or if it's not about the generated files, try to use the -u option of cp.

find "$HOME" -name '*.txt' -type f -print0 | xargs -0 cp -ut "$HOME/newdir" 
 -u copy only when the SOURCE file is newer than the destination file or when the destination file is missing 
Post Undeleted by konsolebox
Post Deleted by konsolebox
Source Link
konsolebox
  • 76.3k
  • 13
  • 110
  • 114

Make it unique in the process. But this require sorting:

find "$HOME" -name '*.txt' -type f -print0 | sort -zu | xargs -0 cp -t "$HOME/newdir" 

Or if it's not about the generated files, try to use the -u option of cp.

find "$HOME" -name '*.txt' -type f -print0 | xargs -0 cp -ut "$HOME/newdir"