Do you have a file in your Downloads folder that you know is a PDF that arrived in the last 4 weeks? You could do a Search in Finder, and specify Kind as PDF, and Date added to within last 4 weeks. You could select all those files and press the Space bar to get them to previsualize them and find visually the one you want.

But you could also use the `find` command in this way:

`find ~/Downloads/ -name "*.pdf" -mtime -4w -print0 | xargs -0 qlmanage -p`

#macOS #UNIX #FindFiles #cli

That command will find things within the Downloads folder that end in “*.pdf” (`-name "*pdf"`) and whose relative time (`-mtime`) with respect to right now is in the last 4 weeks (`-4w`).

Then, it will pass it (`|`) to the `xargs` command, which will use the null separated input (`-0`) from the first command (`-print0`) to execute the `qlmanage` command to preview `-p`.

Hope that's useful!

#macOS #UNIX #FindFiles #cli

For many command line expressions, you can paste them into ExplainShell and you get a description of what every element does:

https://explainshell.com/explain?cmd=find+%7E%2FDownloads%2F+-name+%22*.pdf%22+-mtime+-4w+-print0+%7C+xargs+-0+qlmanage+-p

In this case, the issue is that `qlmanage` is specific to macOS, and does not know what to make of it. So both the description of `qlmanage` and `-p` are wrong.

#macOS #cli #ExplainShell

explainshell.com - find ~/Downloads/ -name "*.pdf" -mtime -4w -print0 | xargs -0 qlmanage -p