Skip to content

Instantly share code, notes, and snippets.

@jbenner-radham
Created September 4, 2019 21:26
Show Gist options
  • Save jbenner-radham/af2925c618cbd4ece7bc7da1f57074ff to your computer and use it in GitHub Desktop.
Save jbenner-radham/af2925c618cbd4ece7bc7da1f57074ff to your computer and use it in GitHub Desktop.
Shell script to list only directories.
#!/usr/bin/env sh
lsdir () {
if [ "${1}" ]; then file=$1; else file='.'; fi
# shellcheck disable=SC2010
ls -Al "${file}" | grep '^d' | awk '{print $NF}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment