In any case, for both -find -mtime +30 and zsh's m+30 glob qualifier, note that it selects files that are 31 days old or older, as it compares the age in terms of integer number of days. type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. You could also use zsh instead whose globs can check files ages (you're already using zsh syntax by not quoting that $USER): oldfiles=(/h/$USER/*.txt(NDm+30^/)) What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. Note that we lose the exit status of find in the process. The grep is to check whether find produces any output (no errors) so we output the No text files to del message if it didn't (remove the > /dev/null if you do want to see the files that we attempt to delete). Grep '^' > /dev/null || echo >&2 No text files to del find /opt/backup -type f -mtime +30 The utility will delete files and folders older. Variation 1 - find all files older than 30 days that end with. First of all, list all files older than 30 days under /opt/backup directory. name '*.txt' ! -type d -mtime +30 -print -exec rm -f + | find all files older than 30 days recursively in current directory find. You could just do: LC_ALL=C find "/h/$USER/." ! -name. An excessive number of files makes it harder to find the files you want and can cause costly mistakes if an outdated file is used or sent accidentally. Shells like bash, when the glob doesn't match any file, pass the glob as-is to find and find complains about that non-existing *.txt file. Powershell list files older than 30 days The above order will discover and show the more established documents which are more seasoned than 30 days in the flow working registries Note that both find -mtime +1 and zsh's (m+1) find files that are at least 48 hours old, not files older than today. txt files are of type directory, it would descend into them to delete all old files there). find /var/log -name '.log'-type f-mtime + 30. Here is the command that you would ideally execute in the Linux OS.
In this section, we are going to see how ansible find is going to help us find the more than 30 days old files. The problem here is that you're using the shell globs instead of find to list the txt files (it will also exclude hidden txt files, and if any. Example1: Find all the log files older than 30 days with Ansible Find.