usage 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. ################################################################################
  3. #
  4. # HPCC SYSTEMS software Copyright (C) 2019 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #################################################################################
  18. declare -a arr1
  19. declare -a arr2
  20. declare -a arrDiscPath
  21. if [ "${1:0:1}" == '-' ]; then
  22. if [ $# -lt 1 ]; then
  23. echo usage: $0 -d=DiskPath[,DiskPath,...]
  24. exit 1
  25. fi
  26. for (( i=1;$i<=$#;i=$i+1 )) do
  27. case ${!i:0:3} in '-d=')
  28. IFS=, read -a arrDiscPath <<< "${!i:3}";;
  29. *)
  30. echo "wrong augument:${!i}";;
  31. esac
  32. done
  33. echo "--Start--"
  34. if [ "${#arrDiscPath[@]}" ]; then
  35. index=0
  36. for i in "${arrDiscPath[@]}"; do
  37. ok=0
  38. dirp=$i
  39. until [ $ok = 1 ] ; do
  40. if [ -d $dirp ] ; then
  41. ok=1
  42. else
  43. dirp=$(dirname $dirp)
  44. fi
  45. done
  46. if [ "$dirp" != "/" ] ; then
  47. dfout=$(df $dirp | tail -n +2 | awk '{if(NF>=4) print $(NF-3) " " $(NF-2)}')
  48. if [ -n "$dfout" ] ; then
  49. arr1[$index]=$(echo $dfout | awk '{print $1}')
  50. arr2[$index]=$(echo $dfout | awk '{print $2}')
  51. if [ "$dirp" != "$i" ] ; then
  52. echo "$i: ${arr1[$index]} ${arr2[$index]} $dirp"
  53. else
  54. echo "$i: ${arr1[$index]} ${arr2[$index]}"
  55. fi
  56. fi
  57. fi
  58. index=$((index+1))
  59. done
  60. fi
  61. echo "--Finish--"
  62. exit 0
  63. fi