0

I'm trying to port the following robocopy command to Linux:

robocopy SrcDir DstDir *.dll *.pdb *.xml /xf Unity*.* nunit*.*

In other words, I want to:

  • Include all dll, pdb and xml files
  • Unless they start with Unity or nunit

I've read the following two threads, but can't figure the exact syntax:

My best guess so far would be:

  • Enable shopt -s extglob
  • Go to the source directory cd SrcDir
  • Use this command: cp ((*.dll | *.pdb | *.xml) && !(Unity*.* | nunit*.*)) DstDir

But I get syntax errors inside my conditional expression, starting at *.dll.

Lazlo
  • 8,518
  • 14
  • 77
  • 116

2 Answers2

2

You may use this command using extglob:

shopt -s extglob nullglob dotglob
cd "$srcDir"

cp !(@(Unity|nunit)).{dll,pdp,xml} "$dstDir"
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

according to below link :

BASH copy all files except one

you can use below command :

find [YOUR_SOURCE_ADDRESS] \( -iname \*.dll -o -iname \*.pdb -o -iname \*.xml \) ! \(-name "Unity*" -o -name "nunit*" \) -exec cp -t [YOUR_DEST_ADDRESS] {} +

you can change [YOUR_SOURCE_ADDRESS] and [YOUR_DEST_ADDRESS] (with your serach address and destination address for copy)

Elham_Jahani
  • 369
  • 2
  • 8