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)?
A/{,.[^.]}* "expands" to A/* A/.[^.]* so mv A/{,.[^.]}* B is also a solution. However mv will bark if there is no dot-file. find A -mindepth 1 -maxdepth 1 -exec mv {} B \; moves dot-{fil,directori}es as well, and does not bark if it can't find a file. Cheers, Leen