I'm currently building a script to handle some files in a directory. In the first example, I use the find command and pass a directory in as the argument. In the second I instead use the -name switch on the find command to pass the desired file-name. Can someone however explain to me the difference between the two below? As they produce exactly the same output:
find dump* -type f -mtime +5 | xargs ls -ltrh
find $dir -type f -name "dump*" -mtime +5 | xargs ls -ltrh
Please assume in the case of the top example that it's being ran in the directory containing the files. In the second however, it can be ran from wherever. My main concern is around the filepath vs -name part; so please focus your attention that way if you can.
Apologies if this has been asked before. I tried looking, but was unable to find anything on it.