Skip to main content
Added more information about patterns in zsh
Source Link

This isn't a feature of cp, it's a feature of your shell (it expands the * to mean all non-dot files), so the answer depends on which shell you're using. For example, zsh supports this syntax:

$ cp ^x /path/to/destination

Where ^x means "all files except x"

You can also combine selection and de-selection patterns, e.g. to copy all wav files except those containing xyz, you can use:

cp *.wav~*xyz*

This isn't a feature of cp, it's a feature of your shell (it expands the * to mean all non-dot files), so the answer depends on which shell you're using. For example, zsh supports this syntax:

$ cp ^x /path/to/destination

Where ^x means "all files except x"

This isn't a feature of cp, it's a feature of your shell (it expands the * to mean all non-dot files), so the answer depends on which shell you're using. For example, zsh supports this syntax:

$ cp ^x /path/to/destination

Where ^x means "all files except x"

You can also combine selection and de-selection patterns, e.g. to copy all wav files except those containing xyz, you can use:

cp *.wav~*xyz*
Source Link
Michael Mrozek
  • 95.7k
  • 40
  • 245
  • 236

This isn't a feature of cp, it's a feature of your shell (it expands the * to mean all non-dot files), so the answer depends on which shell you're using. For example, zsh supports this syntax:

$ cp ^x /path/to/destination

Where ^x means "all files except x"