find
find searches directories by name, type, size and time. -exec runs a command on each result.
Example
d=$(mktemp -d)
mkdir "$d/x"; touch "$d/a.txt" "$d/x/b.txt" "$d/c.log"
find "$d" -name "*.txt" | sed "s|$d/||" | sort
find "$d" -type d | wc -l
find "$d" -name "*.log" -exec basename {} \;
rm -r "$d"Result
a.txt x/b.txt 2 c.log
Exercise
By name.
find . - "*.txt"
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.