home ~ projects ~ socials

Get the Parent Directory of a File Path in bash

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 --