Shell – copy all files that have no extension

cpfilenamesshellwildcards

We can copy some file by extensions like this:

cp *.txt ../new/

but how can I copy all files that have no extension?

Best Answer

The answer from @ubaid-ashraf is almost there. The way to specify file with no extension, in ksh would be:

cp -- !(*.*) /new/path/

so that any file with dot in file name is skipped.

For that to work in bash, you need to enable the extglob option (shopt -s extglob) and the kshglob option in zsh (set -o kshglob).

Related Question