alias gd='_(){ local -i popts=0;[[ "${1}" =~ ^-[sS] ]]&&popts=1&&shift;[[ "${1}" =~ ^-[aA] ]]&&popts=2&&shift;[[ "${1}" =~ ^-[mM] ]]&&popts=3&&shift;local ref="${1%@}";if(($#<1))||[[ "${ref}" =~ ^- || ! -e "${ref}" ]];then echo "Usage: gd [[-s, print size] | [-a, print all] | [-m, print mount point]] <reference file/dir>, arg1=${1},arg2=${2}";[[ ! "${ref}" =~ ^- && ! -e "${ref}" && (($#>0))]]&&echo "*** gd::Error - File (\"${ref}\") not found.";return 1;fi;df -h "$(readlink -f "${ref}")"|awk -vpopts=${popts} "NR==1{header=\$0};NR>1{if(popts==1)print \$1,\$2;else if(popts==2){printf(\"%s\n%-16s%-6s%-5s%-6s%-5s%-20s\n\",header,\$1,\$2,\$3,\$4,\$5,\$6);}else if(popts==3)print \$6;else print \$1;}";};_'
Friday, October 25, 2019
gd / df Wrapper - Optionally Prints Device/Mount/Size for any File/Dir
Simple df -h wrapper that will show the /dev/ or /mnt/ point of any file/dir. It is scriptable and trims trailing @'s for those who like to visualize their links. Get the latest on GitHub.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment