🐸 maurog.earth

an old school website for humans

TIL #1: access arguments in bash

I don't often write bash scripts, so I forget and relearn this twice a year.

#!/bin/bash
echo "All arguments: $@"
echo "Number of arguments: $#"

echo "Path to the script: $0"
echo "First argument: $1"
echo "Second argument: $2"

echo "Loop over arguments:"
for arg in "$@"; do
    echo "  $arg"
done