Is there a way to display all the information that -l does in ls (permissions, dates, etc.) when using the locate or find commands?
Asked
Active
Viewed 485 times
4 Answers
7
Not just for "ls -l" but for whatever action you'd want to perform to your locate or find results you can use xargs or in the case of find the -exec flag. Here are examples to achieve what you want to do:
In the case of locate you can use xargs:
locate something | xargs ls -l
Xargs can be used for find too, but find has the -exec flag that allow to optimize further actions with find results; for example
find . -iname something -exec ls -l '{}' \;
hmontoliu
- 3,793
1
You can use -printf and a suitable format string
find ./ -printf "%M\t%n\t%u\t%g\t%s\t%t%f\n"
- %M Symbolic permissions
- %n hard links
- %u username or numeric user id
- %g group name or numeric group id
- %s file size in bytes
- %t last modification time
- %f filename
user9517
- 116,228
xargsfor find as well, as it handles large result sets better (-execspawns a new process for every file whilexargsgroups them to create as few processes as possible). – Sven Aug 05 '11 at 15:52+e.g.find . -exec ls -l '{}' +. This reduces the number of calls to exec as + puts many of the files found on one command line. – user9517 Aug 05 '11 at 16:04somethingmatches a directory then thels -lprints the contents of the directory too ;) – user9517 Aug 05 '11 at 16:23