Of course, just doing grep Jul
is bad because you might have files with Jul
in their name.
Actually, find
is probably the right tool for your job. Something like this:
find $DIR -maxdepth 1 -type f -mtime -30 -exec cp {} $DEST/ \;
where $DIR
is the directory where your files are (e.g. '.') and $DEST
is the target directory.
The
-maxdepth 1
flag means it doesn't look inside sub-directories for files (isn't recursive)The
-type f
flag means it looks only at regular files (e.g. not directories)The
-mtime -30
means it looks at files with modification time newer than 30 days (+30 would be older than 30 days)the
-exec
flag means it executes the following command on each file, where{}
is replaced with the file name and\;
is the end of the command