Skip to content

Instantly share code, notes, and snippets.

@koumaza
Last active Nov 27, 2019
Embed
What would you like to do?
Disk usage is generate by shell script

Recommand for bash Conform Shell (Non-POSIX compliant) What binary can execute

wget "https://gist.github.com/koumaza/c650a98d855b645894ad2a682934b31b/raw/fb1dcfcc387b8e4b534331ed7b32f8d9618690ac/du_gen.sh" && bash du_gen.sh

(byte+sort)

wget "https://gist.github.com/koumaza/c650a98d855b645894ad2a682934b31b/raw/fb1dcfcc387b8e4b534331ed7b32f8d9618690ac/du_gen_byte.sh" && bash du_gen_byte.sh

(++)

wget "https://gist.github.com/koumaza/c650a98d855b645894ad2a682934b31b/raw/fb1dcfcc387b8e4b534331ed7b32f8d9618690ac/du_gen_byte.sh" && wget "https://gist.github.com/koumaza/c650a98d855b645894ad2a682934b31b/raw/fb1dcfcc387b8e4b534331ed7b32f8d9618690ac/du_gen.sh" && bash du_gen.sh && bash du_gen_byte.sh

(date)

wget "https://gist.github.com/koumaza/c650a98d855b645894ad2a682934b31b/raw/fb1dcfcc387b8e4b534331ed7b32f8d9618690ac/du_gen_date.sh" && bash du_gen_date.sh

#!/bin/bash
du -chx --apparent-size --time-style=full-iso > disk-usage.log
sort -n -r disk-usage.log > disk-usage_sort.log
echo $(echo -e "\e[36;1;4m" Generated)$(echo -e "\e[33;1m")
hr() {
local start=$'\e(0' end=$'\e(B' line='qqqqqqqqqqqqqqqq'
local cols=${COLUMNS:-$(tput cols)}
while ((${#line} < cols)); do line+="$line"; done
printf '%s%s%s\n' "$start" "${line:0:cols}" "$end"
}
hr
echo -e "\e[m"
echo " "$(echo -e "\e[32;1m"+Created)" "$(echo -e "\e[35;1m"disk-usage.log)
echo " "$(echo -e "\e[32;1m"+Created)" "$(echo -e "\e[35;1m"disk-usage_sort.log)
rm du_gen.sh
#!/bin/bash
du -cx --apparent-size --time-style=full-iso > disk-usage-byte.log
sort -n -r disk-usage-byte.log > disk-usage-byte_sort.log
rm disk-usage-byte.log
echo $(echo -e "\e[36;1;4m" Generated)$(echo -e "\e[33;1m")
hr() {
local start=$'\e(0' end=$'\e(B' line='qqqqqqqqqqqqqqqq'
local cols=${COLUMNS:-$(tput cols)}
while ((${#line} < cols)); do line+="$line"; done
printf '%s%s%s\n' "$start" "${line:0:cols}" "$end"
}
hr
echo -e "\e[m"
echo " "$(echo -e "\e[32;1m"+Created)" "$(echo -e "\e[35;1m"disk-usage-byte_sort.log)
rm du_gen_byte.sh
#!/bin/bash
export disk_usage_current_date_du=$(date +%Y-%m-%d_%H:%M:%S)
du -chx --apparent-size --time-style=full-iso > disk-usage_$(echo $disk_usage_current_date_du).log
sort -n -r disk-usage_$(echo $disk_usage_current_date_du).log > disk-usage_$(echo $disk_usage_current_date_du)_sort.log
echo $(echo -e "\e[36;1;4m" Generated $disk_usage_current_date_du)$(echo -e "\e[33;1m")
hr() {
local start=$'\e(0' end=$'\e(B' line='qqqqqqqqqqqqqqqq'
local cols=${COLUMNS:-$(tput cols)}
while ((${#line} < cols)); do line+="$line"; done
printf '%s%s%s\n' "$start" "${line:0:cols}" "$end"
}
hr
echo -e "\e[m"
echo " "$(echo -e "\e[32;1m"+Created)" "$(echo -e "\e[35;1m"disk-usage_$disk_usage_current_date_du.log)
echo " "$(echo -e "\e[32;1m"+Created)" "$(echo -e "\e[35;1m"disk-usage_$(echo $disk_usage_current_date_du)_sort.log)
rm du_gen_date.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment