How to List Files and Folders in a Repository Using Bash
Use standard Bash utilities like ls, find, and git ls-files to explore directory structures, filter by file type, and display only version-controlled assets.
To navigate the microsoft/AI-For-Beginners repository effectively from the terminal, you need to know how to list files and folders in a repository using Bash. This curriculum repository contains top-level directories such as lessons/, etc/, and translations/, along with hundreds of Jupyter notebooks and configuration files. The following commands work on any Git checkout but are particularly useful for exploring this specific AI educational content, as documented in AGENTS.md and the repository root.
Basic Directory Listing with ls
The ls command is the fundamental tool for viewing directory contents. When run at the root of the microsoft/AI-For-Beginners repository, it reveals the primary organizational structure defined in README.md.
cd /path/to/AI-For-Beginners
ls -1
This outputs the top-level layout:
AGENTS.md
CONTRIBUTING.md
LICENSE
README.md
etc
lessons
translations
The -1 flag (the number one) forces single-column output, making it easier to read directory names before drilling deeper into the curriculum.
Recursive and Filtered Searches
Recursive Directory Traversal
To view the entire hierarchy at once, use ls -R for recursive listing. This walks through every subdirectory and prints all nested files, including the Vue.js quiz application under etc/quiz-app/.
ls -R lessons/
While functional, this output can be verbose for large repositories like AI-For-Beginners, which contains numerous lesson subfolders under lessons/1-Intro/ through lessons/6-Other/.
Finding Specific File Types
The find command provides precise filtering capabilities. To locate every Jupyter notebook in the curriculum—essential for identifying which lessons contain executable code—use pattern matching.
find . -name "*.ipynb"
This returns full paths such as:
./lessons/1-Intro/01-WhatIsAI/Intro.ipynb
./lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb
./lessons/4-ComputerVision/07-ConvNets/pytorchcv.ipynb
For a comprehensive file inventory regardless of type, find . -type f prints the path of every standard file while excluding directories.
Visualizing Repository Structure
Using the tree Command
For a graphical representation of the hierarchy, install and use the tree utility. This is particularly effective for visualizing complex nested directories like lessons/4-ComputerVision.
sudo apt install tree # If not already installed
tree lessons/4-ComputerVision
The output displays a clean ASCII tree:
lessons/4-ComputerVision
├── 01-ImageProcessing
│ └── image_processing.ipynb
├── 07-ConvNets
│ ├── pytorchcv.ipynb
│ └── tensorflowcv.ipynb
└── README.md
This view makes it immediately apparent which subdirectories contain implementation files versus documentation.
Listing Version-Controlled Files
Using git ls-files
When you need to see exactly what is tracked by Git—excluding build artifacts, virtual environments, or other untracked files—git ls-files is the authoritative source. This command reads the repository index and lists every version-controlled asset.
git ls-files
According to the microsoft/AI-For-Beginners source code, this includes curriculum notebooks, configuration files, and the Vue.js quiz application under etc/quiz-app/. Unlike filesystem commands, git ls-files respects .gitignore rules and shows hidden files that ls might miss.
Practical Examples for the AI-For-Beginners Repository
Navigate to the repository root and apply these specific commands to explore the curriculum structure:
-
View the Neural Networks lesson structure:
tree lessons/3-NeuralNetworks -
List all markdown documentation:
find . -name "*.md" -type f -
Check which quiz assets are tracked:
git ls-files etc/quiz-app/ -
Quick overview of the translations folder:
ls -R translations/
These commands help you locate specific educational content, verify which files are part of the official repository, and understand the relationship between lesson modules and their supporting materials.
Summary
lsprovides immediate visibility into directory contents, with flags like-Renabling recursive exploration of folders such aslessons/andetc/.findoffers advanced filtering by file type or name, essential for locating specific resources like.ipynbnotebooks in the curriculum.treegenerates visual hierarchies that clarify complex directory relationships in lesson folders likelessons/4-ComputerVision/.git ls-filesdefinitively lists only version-controlled files, making it the most reliable way to audit repository contents against the Git index.- All commands operate on the standard filesystem, but
git ls-filesspecifically queries the Git index for authoritative file tracking in microsoft/AI-For-Beginners.
Frequently Asked Questions
What is the difference between ls and git ls-files?
ls reads the current state of the filesystem, showing all files and directories including untracked downloads, build artifacts, and temporary files. git ls-files queries the Git index and only returns files that are actively tracked by version control, automatically excluding items listed in .gitignore such as Python cache directories.
How do I list only Jupyter notebooks in the lessons folder?
Use the find command with a name pattern and type filter: find lessons/ -name "*.ipynb" -type f. This searches specifically within the lessons/ directory and returns paths like ./lessons/4-ComputerVision/07-ConvNets/pytorchcv.ipynb without including directories or other file types.
Can I see the directory structure without installing the tree command?
Yes. You can approximate the tree view using ls -R, though the output is less visually organized. Alternatively, use find . -type d to list all directories, which helps you understand the folder hierarchy without additional software installation.
Why would I use git ls-files instead of find when listing repository contents?
git ls-files is deterministic and repository-centric—it shows exactly what files belong to the project according to the Git index, regardless of what might be cluttering your local working directory. find is filesystem-centric and will return everything that exists on disk, including untracked files that are not part of the official microsoft/AI-For-Beginners repository.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →