Skip to content

Instantly share code, notes, and snippets.

@scottnunemacher
Created January 31, 2023 23:13
Show Gist options
  • Save scottnunemacher/0ff0b5126126743f5fc074952e9b8815 to your computer and use it in GitHub Desktop.
Save scottnunemacher/0ff0b5126126743f5fc074952e9b8815 to your computer and use it in GitHub Desktop.
Getting the parent of a directory from bash variable
#!/usr/bin/env bash
# From: https://stackoverflow.com/a/42956288
# example: dir=/home/smith/Desktop/Test
parentdir=$(builtin cd $dir; pwd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment