ds (du -sh) to use GNU sort on Linux

This commit is contained in:
2013-05-14 02:31:25 +03:00
parent 01d1ae0371
commit 4c36cda400

16
.rc
View File

@@ -22,11 +22,21 @@ if [ "$(uname -s)" = "Linux" ]; then
alias pgrep='pgrep -lf'
alias crontab='crontab -i'
alias gmake='make'
function ds() {
du -sh "$@" | sort -rh
}
elif [ "$(uname -s)" = "FreeBSD" ]; then
export LSCOLORS=ExGxFxFxCxdxDxabagacac
alias ls='ls -hFIG'
alias pgrep='pgrep -laf'
alias stat="/usr/bin/stat -f \" File: '%N'%SY%n Size: %-15z Blocks: %-10b IO Block: %-6k %HT%nDevice: %7Hr/%-7Lr Inode: %-11i Links: %l%nAccess: (%Mp%Lp/%Sp) Uid: (%5u/%8Su) Gid: (%5g/%8Sg)%nAccess: %Sa%nModify: %Sm%nChange: %Sc%n Birth: %SB\" -t '%F %T %z'"
function ds() {
du -sh "$@" | perl -e '
%byte_order = ( G => 0, M => 1, K => 2, k => 2, 0 => 3 );
print map { $_->[0] } sort { $byte_order{$a->[1]} <=> $byte_order{$b->[1]} || $b->[2] <=> $a->[2] } map { [ $_, /^\s*[\d.]+([MGKk0])/, /^\s*([\d.]+)/ ] } <>'
}
fi
alias nc='nc -vv'
alias snc='openssl s_client -connect '
@@ -120,12 +130,6 @@ function vim() {
fi
}
function ds() {
du -sh "$@" | perl -e '
%byte_order = ( G => 0, M => 1, K => 2, k => 2, 0 => 3 );
print map { $_->[0] } sort { $byte_order{$a->[1]} <=> $byte_order{$b->[1]} || $b->[2] <=> $a->[2] } map { [ $_, /^\s*[\d.]+([MGKk0])/, /^\s*([\d.]+)/ ] } <>'
}
function dl() {
for entry in "$@"; do
printf '%-7d %s\n' $(find $entry | wc -l) "$entry"