hometools

Get the Stem of a File Name in bash

April 2026
#!/bin/bash

EXAMPLE_PATH="path/to/example-file.txt"

BASENAME=$(basename "$EXAMPLE_PATH")
STEM="${BASENAME%.*}"

echo $STEM
example-file