![Find and truncate all files in the oldest subdirectory image 12 - Find and truncate all files in the oldest subdirectory](https://i0.wp.com/pcx3.com/wp-content/uploads/2023/02/image-12.png?resize=701%2C729&ssl=1)
This command will search for directories in the current directory and its subdirectories, find the oldest subdirectory in each directory, and display them on to screen:
find . -maxdepth 1 -type d -exec sh -c 'oldest_folder=$(ls -ltr "$1" | awk "/^d/ {print \$NF; exit}"); echo "$1/$oldest_folder"' sh {} \;
![Find and truncate all files in the oldest subdirectory image 13 - Find and truncate all files in the oldest subdirectory](https://i0.wp.com/pcx3.com/wp-content/uploads/2023/02/image-13.png?resize=736%2C373&ssl=1)
To truncate all files in those oldest subdirectories (snap.X on the screenshot above) use:
find . -mindepth 1 -type d -exec sh -c 'oldest_folder=$(ls -ltr "$1" | awk "/^d/ {print \$NF; exit}"); > "$1/$oldest_folder"/*' sh {} \;