Timeline for Get list of directories with more than 20,000 files/subdirectories
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 24, 2023 at 11:55 | vote | accept | STF | ||
| Jan 24, 2023 at 11:31 | comment | added | Kusalananda♦ | @STF Yes, that is expected. You will have to add a few semi-colons if you want to fold it into a single line: find . -type d -exec sh -c 'for dirpath do set -- "$dirpath"/*; [ "$#" -gt 20000 ] && printf "%s\n" "$dirpath"; done' sh {} + | |
| Jan 24, 2023 at 11:28 | comment | added | STF | ♦ I tried the script in one line and got: find . -type d -exec sh -c 'for dirpath do set -- "$dirpath"/* [ "$#" -gt 20000 ] && printf "%s\n" "$dirpath" done' bash {} + bash: -c: line 1: syntax error: unexpected end of file bash: -c: line 1: syntax error: unexpected end of file bash: -c: line 1: syntax error: unexpected end of file bash: -c: line 1: syntax error: unexpected end of file | |
| Jan 24, 2023 at 11:25 | comment | added | Kusalananda♦ | @STF The commands, as given, will operate on the current directory (and it will recursively descend into subdirectories). If you need to point the find command elsewhere, then change the . after find to the desired top-level directory. Do not modify dirpath in the script, it's a variable that the script uses and its values will be provided by find. | |
| Jan 24, 2023 at 11:07 | comment | added | STF | What should I write in dirpath? my dir path? | |
| Jan 24, 2023 at 10:19 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 317 characters in body |
| Jan 24, 2023 at 10:14 | history | answered | Kusalananda♦ | CC BY-SA 4.0 |