Post History
Here's my approach: find l1 -type d \ | while read d; do find $d -maxdepth 1 -type f \ | head -n3; done; If your middle directories also contain files, it will also show them (of course, ...
Answer
#11: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
| sort \- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
#10: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
done \| sort;- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
#9: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
| sort \| while read d; dofind $d -maxdepth 1 -type f \| sort \| head -n3;done;```Or you could sort just once after `done`, depending on your needs. It may be faster or slower, depending on what you do with it. Please try both. Also, the order is slightly different for directories that contain both files and other directories.```shfind l1 -type d \- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done \
- | sort;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done \
- | sort;
- ```
#8: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
Or you could sort just once after `done`, depending on your needs. It may be faster or slower, depending on what you do with it. Please try both. Also, the sort is slightly different for directories that contain both files and other directories.- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done \
- | sort;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
- Or you could sort just once after `done`, depending on your needs. It may be faster or slower, depending on what you do with it. Please try both. Also, the order is slightly different for directories that contain both files and other directories.
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done \
- | sort;
- ```
#7: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
Or you could sort just once after `done`, depending on your needs. It may be faster or slower, depending on what you do with it. Please try both.- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done \
- | sort;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
- Or you could sort just once after `done`, depending on your needs. It may be faster or slower, depending on what you do with it. Please try both. Also, the sort is slightly different for directories that contain both files and other directories.
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done \
- | sort;
- ```
#6: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
- Or you could sort just once after `done`, depending on your needs. It may be faster or slower, depending on what you do with it. Please try both.
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done \
- | sort;
- ```
#5: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- This is what it shows for me in a tree similar to yours, where I added files to `l2`:
- ```sh
- $ find l1 -type d | while read d; do find $d -maxdepth 1 -type f | head -n3; done;
- l1/l2/f2
- l1/l2/f5
- l1/l2/f4
- l1/l2/d0/f2
- l1/l2/d0/f5
- l1/l2/d0/f4
- l1/l2/d5/f2
- l1/l2/d5/f5
- l1/l2/d5/f4
- l1/l2/d4/f2
- l1/l2/d4/f5
- l1/l2/d4/f4
- l1/l2/d2/f2
- l1/l2/d2/f5
- l1/l2/d2/f4
- l1/l2/d1/f2
- l1/l2/d1/f5
- l1/l2/d1/f4
- l1/l2/d3/f2
- l1/l2/d3/f5
- l1/l2/d3/f4
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
#4: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If your middle directories also contain files, it will also show them (of course, only the first 3).
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
#3: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
sort \- | while read d; do
- find $d -maxdepth 1 -type f \
sort \- | head -n3;
- done;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- | sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | sort \
- | head -n3;
- done;
- ```
#2: Post edited
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria <https://serverfault.com/questions/181787/find-command-default-sorting-order>:- ```sh
- find l1 -type d \
- sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- sort \
- | head -n3;
- done;
- ```
- Here's my approach:
- ```sh
- find l1 -type d \
- | while read d; do
- find $d -maxdepth 1 -type f \
- | head -n3;
- done;
- ```
- If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria (see <https://serverfault.com/questions/181787/find-command-default-sorting-order>):
- ```sh
- find l1 -type d \
- sort \
- | while read d; do
- find $d -maxdepth 1 -type f \
- sort \
- | head -n3;
- done;
- ```
#1: Initial revision
Here's my approach: ```sh find l1 -type d \ | while read d; do find $d -maxdepth 1 -type f \ | head -n3; done; ``` If you want the first 3 files in a certain order, you'll need to sort(1) them according to your needs; otherwise, you'll get the first three files according to find(1)'s default criteria <https://serverfault.com/questions/181787/find-command-default-sorting-order>: ```sh find l1 -type d \ sort \ | while read d; do find $d -maxdepth 1 -type f \ sort \ | head -n3; done; ```