Search code examples
unixcurly-bracesexpansion

How to delete all files of multiple extensions with brace expansion unix?


What am i getting wrong here?

I'm trying to move all the .json and .py from /home/myname/foo/ to /home/myname/foo/.

I've tried, while in directory myname,
mv ./foo/{*.json, *.py} ./bar/
as well ass mv ./foo/*{.json, .py} ./bar/,

but to no avail. Would love to learn how to use the expansion correctly of course more than to move the files. Thank you.


Solution

  • Omit the space. Either ./foo/*.{json,py} or ./foo/*{.json,.py} should work.

    Or, simpler but slightly longer, mv ./foo/*.json ./foo/*.py ./bar.