Get the Parent Directory of a File Path in bash

May 2025
SOME_PATH="/this/is/the space named/folder/file.txt"
PARENT_DIR="$(dirname "$SOME_PATH")"

echo $PARENT_DIR
Output:
/this/is/the space named/folder
end of line