Last active
October 8, 2019 08:28
-
-
Save gMan1990/6c061392e2c4577ff7c9dc3c289b66fe to your computer and use it in GitHub Desktop.
android tool shell: https://termux.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/bash | |
# ln -s /proc/self/fd /dev/fd | |
# https://forum.xda-developers.com/android/software-hacking/dev-lastest-bash-android-t2898295 | |
## mount -o remount,rw /system | |
# toolbox ls -la /sdcard/Download | |
# toybox ls -lFA /sdcard/Download | |
## find -path bug: https://github.com/landley/toybox/issues/73 | |
# busybox ls -lFA /sdcard/Download | |
## ls -lFhA /system/*bin/*box /system/*bin/*box? /data/tmp /sdcard/Download | |
## /data/data/com.termux/files /data/data/com.sonelli.juicessh/files | |
date "+%F %T" >&2 | |
du1() { | |
if [ "$2" ]; then | |
if [ ! -L "$1" ] && [ -d "$1" ]; then | |
#if [[ $1 == *'/' ]]; then dx="$1"; else dx="$1/"; fi | |
while IFS= read -r -d '' x; do | |
if [ "$x" ] && [ "$x" != "/proc" ] && [[ $x != *'/emulated/0' ]]; then | |
du1 "$x" "b1" | |
fi | |
done < <(busybox3 find "$1" -mindepth 1 -maxdepth 1 -print0) | |
else | |
if size="$(stat -c "%s" "$1")"; then | |
total="$((total + size))" | |
fi | |
fi | |
elif [ -d "$1" ]; then # dL(0) / d | |
#if [[ $1 == *'/' ]]; then dy="$1"; else dy="$1/"; fi | |
while IFS= read -r -d '' y; do | |
if [ "$y" ] && [ "$y" != "/proc" ] && [[ $y != *'/emulated/0' ]]; then | |
total=0 | |
du1 "$y" "b2" | |
printf "%d\t%s\n" "$total" "$y" | |
fi | |
done < <(busybox3 find "$1" -mindepth 1 -maxdepth 1 -print0) | |
else # f,S,b,c,p | |
exit 1 | |
fi | |
} | |
if [ "$1" ]; then du1 "$1"; else du1 "."; fi | |
echo "$(date "+%F %T") exit $?" >&2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
du with
--exclude
for android...https://github.com/vmchale/tin-summer
fd is a simple, fast and user-friendly alternative to find.
https://github.com/sharkdp/fd