Celeb Glow
general | March 20, 2026

Move folders that have an apostophe in their name

Hoping this is an easy one - can't quite get it to work.

I need to move all folders, and content (no sub folder) that have at least one apostrophe/quote in their name.

Any pointers?

2

2 Answers

You need to escape ' using one of the usual escaping methods. BTW the glob pattern you will need is *<glob_pattern_here>*/, the trailing / will make the shell to match only directory(ies).

  • Using backslash, \:

    mv -t /destination/ *\'*/ 
  • Using double quotes, ":

    mv -t /destination/ *"'"*/
  • Using single quotes, ', this is actually same as using the backslashed one:

    mv -t /destination/ *''\'''* 

You can do a echo mv ... first as a dry-run. Replace /destination/ with your actual destination.

Also, you can try to use tab-completion if you feel to do it interactively.

2

I'm sure there are simpler ways, but this should work in sh with no spaces in the file name

mv *[\"\']* 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy