I have a folder with images(png, bmp, jpg) and extension-less files.
I can't figure out how to move only the extension-less files. They are all random numbered files.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
!(...) ksh extended glob operator for negation, so in
zsh -o kshglob or
bash -O extglob:
rm -- !(*.*) /dest
Would move the files whose name doesn't contain a dot (note that in shells other than
zsh, if there's no such file, it could still move the file called
!(*.*) even though that file does contain a dot).
^ extended glob operator for negation, so in
zsh -o extendedglob:
rm -- ^*.* /dest
In all the above, hidden files would not be moved, first because their name does contain a dot (they start with a dot), but also because hidden files are excluded from globs unless the glob itself starts with a literal
If you want to also move
.foo files but not
.foo.png, you can do:
mv -- ^?*.*(D) /dest # with zsh -o extended-glob mv -- !(?*.*) /dest # with bash -O extglob -O dotglob # or zsh -o kshglob -o dotglob -o nobareglobqual # or env FIGNORE='@(.|..)' ksh93 mv -- @(.|)+([^.]) /dest # with bash -O extglob or AT&T ksh