Skip to content
Snippets Groups Projects
Verified Commit d19b2eda authored by Renato Alves's avatar Renato Alves :seedling:
Browse files

ENH perms - display permissions of target up to the root of the filesystem

parent d2d443c5
No related branches found
No related tags found
No related merge requests found
EMBL utilities
==============
``perms`` - a script to display permissions of a target file/folder up to the root of the filesystem (useful when granting permissions to someone else).
``submitjob`` - a polyglot script that submits jobs to SGE, LSF and SLURM clusters.
#!/usr/bin/env bash
# perms.sh -- created 2016-06-05, Renato Alves
usage() {
echo >&2 ""
echo >&2 "Usage:"
echo >&2 " $0 [path]"
echo >&2 ""
echo >&2 "Optional parameters:"
echo >&2 " path = if not given, the current work directory is used"
echo >&2 ""
}
function uptree {
[ "x$1" == "x" ] && return
# NOTE The \ in \ls is meant to ensure 'ls' is not a shell alias
( \ls -ld -- "$1"; [ "$1" = '/' ] && return; uptree "$(dirname "$1")") | column -t
}
# Parse args using getopt (instead of getopts) to allow arguments before options
ARGS=$(getopt -o h -n "$0" -- "$@")
# reorganize arguments as returned by getopt
eval set -- "$ARGS"
while true; do
case "$1" in
# Shift before to throw away option
# Shift after if option has a required positional argument
-h)
shift
usage && exit 0
;;
--)
shift
break
;;
esac
done
if [ "$#" == "1" ]; then
DIR=$(readlink -f "$1")
else
DIR=$(pwd -P)
fi
uptree "$DIR"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment