HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to BashNumbers & ArithmeticStringsArraysConditions (if)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output & Input
📦 Variables
🔢 Numbers & Arithmetic
✍️ Text
📋 Array
🔁 Condition & Loop
🧩 Functions & Pipes
FunctionPipe ( | )
Bash›REFERENCE›Functions & Pipes
🧩

Functions & Pipes

Functions and command chaining.

CommandDescription
FunctionDefines your own command.
Pipe ( | )Passes the output of one command to another.

Function

Try it yourself →

Defines your own command.

Syntax

name() { ... }

Description

Parameters are accessed with $1, $2 ... 'Returns' with echo (actual return code is return).

Example

greet() {
  echo "Hello $1"
}
greet "Alex"

Expected output

Hello Alex

When to use?

Preventing code repetition.

Pipe ( | )

Try it yourself →

Passes the output of one command to another.

Syntax

komut1 | komut2

Description

| (pipe) takes the output of the left command as input for the right command. The heart of the Unix philosophy.

Example

echo "c\nb\na" | sort

Expected output

a
b
c

When to use?

Chaining commands (filtering, sorting, counting).

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code