# Checking Before You Act: File Tests

File tests let a script look before it acts: -e asks whether a path exists, -f and -d whether it's a file or a folder, -s whether a file has anything in it, and -nt whether it's newer than another.

![Cheat sheet for the lesson Checking Before You Act: File Tests: File tests let a script look before it acts: -e asks whether a path exists, -f and -d whether it's a file or a folder, -s whether a file has anything in it, and -nt whether it's newer than another.](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/b980f8ff34fb4200b8301a3279f2b64e.webp)

- Category: Bash
- Level: Apprentice
- Tags: Directory, file-test, linux, modification-time, test-command, unix
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/bash-file-tests-cheat-sheet
