Skip to content

Instantly share code, notes, and snippets.

@ThatsJustCheesy
Last active January 13, 2021 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThatsJustCheesy/bec25a8fd1ff05d197b685b07b0c06f9 to your computer and use it in GitHub Desktop.
Save ThatsJustCheesy/bec25a8fd1ff05d197b685b07b0c06f9 to your computer and use it in GitHub Desktop.
bash script that describes typical filesystem objects—lists directories, describes files, and resolves links on the way
#!/bin/bash
script_canonical_name='?'
file="${1:-$(pwd)}"
if [[ -h "$file" ]]
then
echo "$script_canonical_name: is a link to $(readlink "$file")"
file=$(realpath "$file")
fi
if [[ -d "$file" ]]
then
ls -p "$file"
else
file "$file"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment