10 Mar
2005
10 Mar
'05
23:45
On Friday 11 March 2005 00:31, Paul W. Abrahams wrote:
Here's a little command-line puzzle. Suppose you want to move all files from directory A to directory B. You might think that
mv A/* B
would do it. But no -- that doesn't move the dotfiles. So how about
mv A/* A/.* B
No -- that tries to move "." and "..". So how about mv A/* A/.?* B
That still tries to move "..", but not ".". Finally, how about
mv A/* A/.[^.]* B
That actually does it, I think -- but it's very inelegant. Does anyone have an elegant solution (that works for other commands also)?
shopt -s dotglob mv A/* B/ Have a look at "man bash" for a description of shopt, dotglob and the other possibilities available