I'm assuming that you have GNU find
. If you want to move files or directories modified within a certain time span (e.g. March 2014) do this:
find . -maxdepth 1 \ -newermt 2014-02-28 -not -newermt 2014-04-01 \ -not -name 'build_tools' \ -exec mv {} build_tools \+
Explanation:
- find in this directory, without subdirectories
- files in the range between Feb. 28th and April 1st, where
mt
refers to modification time. You could also usect
to search for creation time. - that aren't named
build_tools
- move all of them to
build_tools
. The\+
means that all found file/directory names are replaced in{}
, instead of one at a time. If you want one at a time, you need\;
instead.
A couple of things:
Don't parse the output of
ls
. The format is dependent on the operating system, and picking columns withawk
fails if the file / directory names contain whitespace.You used
&
to concatenate commands, but&
just puts a process into the background. If at all, you should have used&&
, but all in all, it'd be rather complicated to achieve what you want.