Tsallaka zuwa abun ciki
Justice Tech School

find and xargs

find searches folders by name, type, size or age and can run commands on results. Combine with xargs for speed. Use -print0 and -0 for odd filenames.

Example
d=$(mktemp -d); cd "$d"
mkdir sub; touch a.log b.txt sub/c.log
find . -name "*.log" | sort
find . -type d | sort
find . -name "*.log" -print0 | xargs -0 -n1 basename | sort
find . -type f -empty | wc -l
cd /; rm -r "$d"

Result

./a.log
./sub/c.log
.
./sub
a.log
c.log
3

Exercise

Search for directories.

find . -type 

Quiz Test

Which option matches names?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.