Linux and Unix/SHELL
쉘 스크립트 df -h 명령어 특정 용량 이상 디렉토리 가져오기
산에서 자라는 아침의 나무
2023. 2. 13. 00:01
시스템 관리시에 특정 디렉토리의 용량을 구해야 하는 경우가 있다.
아래 스크립트를 활용해보자
#!/bin/bash
mount_used=(`df -h`)
cnt=0
for mount_used_item in ${mount_used[*]}
do
if [[ "$mount_used_item" =~ [1-9][0-9][%] ]]; then
cnt3=$cnt
cnt2=`expr $cnt + 1`
echo "사용률:${mount_used[$cnt3]}, 디렉토리: ${mount_used[$cnt2]}"
fi
cnt=`expr $cnt + 1`
done