-1

I have to display all files and folders details under a parent directory. I am using the command is 'find'. For example,

find /usr/local

/usr/local/bin

It's display only the file name. I have to display file name with details about files like below. Means I have to add below information in the above result set.

-rw-rw-- 1 hduser hduser 213 jan 22 11:51

How to do it?

Thanks in advance.

jww
  • 97,681
  • 90
  • 411
  • 885
Fazil
  • 51
  • 2
  • 4
  • Possible duplicate of [How do I get the find command to print out the file size with the file name?](https://stackoverflow.com/q/64649/608639), [find -exec with multiple commands](https://stackoverflow.com/questions/5119946/find-exec-with-multiple-commands), etc. – jww Feb 23 '18 at 11:41

3 Answers3

3

There's the convenient action -ls:

find /usr/local -ls

If you need some other than the default -ls output format, the action -printf is appropriate; with that you can freely define the format, e. g.:

find /usr/local -printf "%i,%k,%M,%n,%u,%g,%s,%t,%p\n"

Cf. man find: Print File Information.

Armali
  • 18,255
  • 14
  • 57
  • 171
  • 1
    I'm using 'find /usr/local -ls' It's showing like below. 19799045 4 drwxr-xr-x 9 hduser root 4096 Feb 23 11:00 /usr/local I have to do the comma seperated like below. 19799045,4,drwxr-xr-x,9,hduser,root,4096,Feb 23 11:00,/usr/local How to do it. Thanks in advance. – Fazil Feb 23 '18 at 12:10
0

you can use below command to list it nicely in a order and block wise:-

find . -type d |xargs ls -ltr

For your case:-

find /usr/local -type d |xargs ls -ltr
Abhijit Pritam Dutta
  • 5,521
  • 2
  • 11
  • 17
-1

Try sudo find /usr/local -name "filename" -depth -exec ls -ll {} \;

Juliano Petronetto
  • 1,067
  • 13
  • 15
  • 1
    Why making it too complex. See the answer by [Armali](https://stackoverflow.com/a/48947137/7975442) – C0deDaedalus Feb 23 '18 at 13:26
  • I don't see this complexity, if you see, probably you need study more... And this SIMPLE command can be extended do various and useful things, like delete all *.pyc files for example, `find /path/to/folder -name "*.pyc" -depth -exec rm {} \;` – Juliano Petronetto Feb 25 '18 at 02:58
  • Yes your command can be extended to do various useful things, but that doesn't fits as a `SIMPLE` answer to OP. BY the way, I didn't downvoted your answer. – C0deDaedalus Feb 25 '18 at 13:21
  • I still can't see where is this complexity that you talking about, I only introduce 2 more params. – Juliano Petronetto Feb 26 '18 at 12:56