Shell – How to move some but not all files from one directory to another

cpfilenamesrenameshell

I need to move my files from one directory to other. But there is some issues. My file name pattern is like:

  apple.0, apple.<n>, n -> {0,1,2,3 ...~ }

so mv apple.* will not work, because I need to keep apple.0, which is always the active one.

How do I move them with exceptions (in this case, keeping apple.0)?

Best Answer

If you have bash and don't care about also matching files like apple.not-a-number, try

shopt -s extglob
mv apple.!(0) /new/directory
Related Question