Skip to content
Home
Dev Convert Generate Finance Calc Design Security Media

More categories

Productivity 23 SEO Tools 18 Network Tools 17 Text Tools 16 Education Tools 15 PDF Tools 11 Mockups 9

Learn and build

GuidesBlogAPI & MCPCheatsheetsChangelog All categories

Browse

439 tools · 15 categories

Start here

Popular tools New this week 11 All tools 439

Categories

Developer Tools 91 Converters 65 Calculators 32 Finance Tools 32 Generators 31 Media Tools 27 Design Tools 25 Security Tools 25 Productivity 23 SEO Tools 18 Network Tools 17 Text Tools 16 Education Tools 15 PDF Tools 11 Mockups 9

Learn and build

Guides Cheatsheets Blog REST API MCP server Changelog

No matches here.

Keep FindUtils free Sponsors fund new tools
  1. Cheatsheets
Guides Blog API & MCP
Sponsor
FindUtils
Sponsor
  1. Home
  2. Cheatsheets
  3. Linux & Terminal
  4. Bash Scripting

Linux & Terminal · Cheatsheet

Bash Scripting Cheatsheet

Variables, loops, conditionals, functions, and scripting patterns for Bash shell

53 commands 7 sections

On this sheet

Variables & Strings 10 Conditionals 10 Loops 8 Functions 8 Input/Output & Redirection 9 Special Variables 7 Sources 1

No entry matches that filter.

Variables & Strings

  • NAME="value" Assign variable (no spaces around =)
  • $NAME or ${NAME} Reference variable
  • "Hello $NAME" String with variable interpolation
  • 'Hello $NAME' Literal string (no interpolation)
  • ${#STR} String length
  • ${STR:0:5} Substring (offset:length)
  • ${STR/old/new} Replace first occurrence
  • ${STR//old/new} Replace all occurrences
  • ${STR^^} Uppercase entire string
  • ${STR,,} Lowercase entire string

Conditionals

  • if [ condition ]; then ... fi Basic if statement
  • if [[ $a == $b ]]; then ... Extended test (preferred)
  • -eq -ne -lt -gt -le -ge Numeric comparisons
  • == != String comparisons (inside [[ ]])
  • -z "$STR" True if string is empty
  • -n "$STR" True if string is non-empty
  • -f <file> True if file exists and is regular
  • -d <dir> True if directory exists
  • -e <path> True if path exists (file or dir)
  • && || Logical AND / OR

Loops

  • for i in 1 2 3; do ... done For loop over list
  • for i in {1..10}; do ... done For loop with range
  • for f in *.txt; do ... done For loop over files (glob)
  • for ((i=0; i<10; i++)); do ... C-style for loop
  • while [ condition ]; do ... done While loop
  • while read -r line; do ... done < file Read file line by line
  • break Exit loop
  • continue Skip to next iteration

Functions

  • function name() { ... } Define a function
  • name() { ... } Define function (shorthand)
  • $1 $2 $3 Function arguments (positional)
  • $# Number of arguments
  • $@ All arguments as separate words
  • $? Exit status of last command
  • return <n> Return exit code from function
  • local var="value" Local variable in function

Input/Output & Redirection

  • echo "text" Print text to stdout
  • printf "%s\n" "text" Formatted output
  • read -p "Prompt: " VAR Read user input into variable
  • cmd > file Redirect stdout to file (overwrite)
  • cmd >> file Redirect stdout to file (append)
  • cmd 2> file Redirect stderr to file
  • cmd &> file Redirect both stdout and stderr
  • cmd1 | cmd2 Pipe stdout of cmd1 to cmd2
  • cmd < file Redirect file as stdin

Special Variables

  • $0 Script name
  • $$ Current process ID (PID)
  • $! PID of last background process
  • $? Exit status of last command
  • $_ Last argument of previous command
  • RANDOM Random number (0-32767)
  • SECONDS Seconds since script started

Sources

  • https://www.gnu.org/software/bash/manual/ GNU Bash: variables, expansion, conditions, loops, functions, and redirection.

Related cheatsheets

  • Linux Commands61 commands
  • Vim Editor64 commands
  • SSH Commands54 commands

Guides that use these commands

  • JSON to PDF Guide: Build Documents and Check Export LimitsGuide · 9 min read

From FindUtils

More to explore

Products and services from the team behind FindUtils.

Promote your tool
Featured product seeranks.com SeeRanks — transparent product discovery A public ranking board where paid placement is always labeled and every product keeps its earned position. View SeeRanks Public rank board #1 Sponsored #2 #3 #4 Paid placement is always labeled Free favicon tool emojifavicons.com Emoji Favicons Turn any emoji into a favicon with one HTML line. SVG, PNG or ICO, no sign-up. <link rel="icon" href=".../🦊.svg"> Create a favicon
FindUtils service findutils.com Articles for software tools A sourced article for your channels, or a sponsored FindUtils publication with editorial review. Compare packages Domain portfolio findutils.com Domain names for sale .com.dev.sh.app.io Unused names across dev tools, AI, PDF and commerce. Make an offer. Browse the list Playable ranking towerscore.io TowerScore — stack the skyline Play to climb, or buy a floor. Paid floors are labeled. Open TowerScore

Missing a tool you need?

Tell us what to build next. Most requests ship as a free browser tool, an API endpoint and an MCP tool.

Request a tool
FindUtils

Free, fast utilities. Most tools process your files in the browser; lookup tools say what they send, and pages load analytics and ads.

  • No sign-up for free tools
  • Most tools run in your browser
  • 369 tools on the REST API, 369 on MCP

Tools

DevelopersConvertPDFDesignSecurityAll tools →

Learn

GuidesBlogCheatsheetsChangelog

Build

REST APIMCP serverAPI referenceWorkflowsStatus

FindUtils

AboutLibraries we useSponsorRequest a toolDomains for saleContact
© 2026 FindUtils PrivacyTermsSitemap
Service status
FindUtils

Free, fast utilities that respect your data. Most tools run in your browser.

Build with it

REST APIMCP serverGuidesChangelog

FindUtils

AboutSponsorPrivacyContact
Theme
© 2026 FindUtils Terms
FindUtils
Guides Blog REST API MCP server Changelog

Categories

Developers 91 Convert 65 Calculate 32 Finance 32 Generate 31 Media 27
All 15 categories →

Keep it free

Sponsorship keeps every tool free and funds the new ones we ship each week.

Sponsor Back the project
Tools API Sponsor