Post History
There's three parts to this: Find all directories (in your case, sounds like you want depth=3 only) Print the top 3 files in a single directory Apply 2 to each in 1 1 should be a separate q...
Answer
#2: Post edited
There's two parts to this:- 1. Find all directories (in your case, sounds like you want depth=3 only)
- 2. Print the top 3 files in a single directory
- 3. Apply 2 to each in 1
- 1 should be a separate question but both `find` can do it. I prefer `fd`: `fd --type directory . --max-depth 3 --min-depth 3`. There might be a shorter way to request a depth of exactly 3 but I don't know it.
- 2 is obviously done with `head -n 3`.
- 3 can be done as described in https://linux.codidact.com/posts/288310.
- Putting it all together, it would be something like this:
- ```
- fd --type directory . --max-depth 3 --min-depth 3 \
- | parallel 'fd --type file . {} | head -n 3'
- ```
- There's three parts to this:
- 1. Find all directories (in your case, sounds like you want depth=3 only)
- 2. Print the top 3 files in a single directory
- 3. Apply 2 to each in 1
- 1 should be a separate question but both `find` can do it. I prefer `fd`: `fd --type directory . --max-depth 3 --min-depth 3`. There might be a shorter way to request a depth of exactly 3 but I don't know it.
- 2 is obviously done with `head -n 3`.
- 3 can be done as described in https://linux.codidact.com/posts/288310.
- Putting it all together, it would be something like this:
- ```
- fd --type directory . --max-depth 3 --min-depth 3 \
- | parallel 'fd --type file . {} | head -n 3'
- ```
#1: Initial revision
There's two parts to this: 1. Find all directories (in your case, sounds like you want depth=3 only) 2. Print the top 3 files in a single directory 3. Apply 2 to each in 1 1 should be a separate question but both `find` can do it. I prefer `fd`: `fd --type directory . --max-depth 3 --min-depth 3`. There might be a shorter way to request a depth of exactly 3 but I don't know it. 2 is obviously done with `head -n 3`. 3 can be done as described in https://linux.codidact.com/posts/288310. Putting it all together, it would be something like this: ``` fd --type directory . --max-depth 3 --min-depth 3 \ | parallel 'fd --type file . {} | head -n 3' ```