I'm using the below command but it is not working
find . PYRLLPS_GL_201610D2* -maxdepth 1 -mtime -30
I get the below error
find: bad option -maxdepth
find: [-H | -L] path-list predicate-list
-maxdepth is not specified by POSIX. It appears your version of find doesn't support that primary.
Ways to accomplish the same effect using only POSIX options are discussed here:
Also, it's unclear what you're trying to do but you may have the usage of find itself confused:
If you are trying to find all files with names that start with PYRLLPS_GL_201610D2, you should be using the -name operator, and protecting the pattern itself from expansion (shell globbing) so that find sees the pattern itself, rather than the pattern being expanded by the shell.
Something like so:
find . -path '*/*/*' -prune -o -name PYRLLPS_GL_201610D2\* -mtime -30 -print
If you are trying to find all files with -mtime -30 that are directly within either the current directory or within one of the PYRLLPS_GL_201610D2* directories in the current directory, then you have the right idea and are just missing the -maxdepth workaround linked above.
some `backticks` around your inline code, please. I take it you included the backslash before the *? That part is important.
– Wildcard
Apr 19 '16 at 08:12
find . -maxdepth 1 -name PYRLLPS_GL_201610D2* -mtime -30
If you want to find file named like PYRLLPS_GL_201610D2AAAA ,you need the code:
find . -maxdepth 1 -name 'PYRLLPS_GL_201610D2*' -mtime -30
find . -name 'PYRLLPS_GL_201610D2*' …instead. Without-namethe shell has to read the current directory, expand the glob expression, pass all results tofind, which in turn will filter for modification time. With-name,findwill take care of everything, and no potentially large argument list needs to be passed around. – johnLate Apr 20 '16 at 14:49