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?
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.
''\'''
is the same as \'
since each ''
is a single-quoted null string.
– wjandrea
Apr 18 '17 at 16:36
I'm sure there are simpler ways, but this should work in sh
with no spaces in the file name
mv *[\"\']*
mv
is one of the tags, I'd assume that they're using that. – TheOdd Apr 18 '17 at 15:47