Coding for All
Level 23: Finding Files
Finding Files Hunt for files anywhere below where you are standing.

find walks through a folder and everything inside it, however deep, looking for names that match. The . means "start from the folder I am standing in".

The -name flag says what to look for, and the quotes matter here: they keep the * safe so that find (not bash) gets to do the matching. Without the quotes bash would expand the star first, and find would be looking for the wrong thing.

Look carefully at the answers: find reaches into notes and homework as well. That is the difference between find and ls. ls tells you what is here; find tells you what is anywhere below here.

find . -name "*.txt"Every .txt file below here.
find . -name "ideas.txt"Hunt for one particular name.
find notes -name "*.txt"Search one folder only.
Your task
  • Find every .txt file below this folder
  • Check it reached inside the notes folder

Open this level in your browser to type the commands at a live terminal that answers back.