You could also use -type f if you only want to copy things that are strictly files, but I prefer the above because it also catches everything that's neither a file nor a directory (in particular symbolic links)
-exec mv -t "$TARGET_DIR" -- '{}' +: Run the command mv -t "$TARGET_DIR" -- FILES... where FILES... are all the matching files (thanks @DavidFoerster)
Best Answer
If you want to move everything except directories from
$SOURCE_DIR
to$TARGET_DIR
, you can use this command:Explained in detail:
find
: The find search for files in a directory$SOURCE_DIR
: The directory to search in-maxdepth 1
: Do not look inside subdirectories-not -type d
: Ignore directories-type f
if you only want to copy things that are strictly files, but I prefer the above because it also catches everything that's neither a file nor a directory (in particular symbolic links)-exec mv -t "$TARGET_DIR" -- '{}' +
: Run the commandmv -t "$TARGET_DIR" -- FILES...
whereFILES...
are all the matching files (thanks @DavidFoerster)