GitHub
On this page Contents

Bash

File commands

Basic Bash file commands for listing, reading, and removing files.

Simple Bash commands for checking what is in a folder, reading file contents, and deleting files or folders.

List files with ls #

ls lists the files and folders in the current directory.

Shell
ls

You can also point it at a specific path:

Shell
ls some-folder

Use this when you want to quickly see what is inside a folder.

Read file contents with cat #

cat prints file contents to the terminal.

Shell
cat some-file.md

Use this when you want to quickly read a small file without opening an editor.

Remove files with rm #

rm removes files.

Shell
rm old-file.txt

Be careful: this deletes the file instead of moving it to a recycle bin.

What -f means #

-f means force.

Shell
rm -f old-file.txt

This tells rm:

  • do not ask for confirmation
  • do not complain if the file does not exist

Use it when you want rm to stay quiet and just try the deletion.

What -r means #

-r means recursive.

Shell
rm -r old-folder

This tells rm to remove a folder and everything inside it.

What -rf means #

-rf combines both flags:

  • -r = recursive
  • -f = force
Shell
rm -rf old-folder

This removes the folder and everything inside it without asking.

Use rm -rf carefully, because it can delete a lot very quickly.

Search docs

Use / or CtrlK to search

Start typing to search the docs.