Skip to content

Instantly share code, notes, and snippets.

@gMan1990
Last active October 8, 2019 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gMan1990/6c061392e2c4577ff7c9dc3c289b66fe to your computer and use it in GitHub Desktop.
Save gMan1990/6c061392e2c4577ff7c9dc3c289b66fe to your computer and use it in GitHub Desktop.
android tool shell: https://termux.com
#!/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
@gMan1990
Copy link
Author

gMan1990 commented Sep 22, 2019

#!/system/bin/bash
date "+%F %T" >&2

# find / -not -name "*[0-9A-Z_a-z\-][._]*" "(" -name "bash*" -o -name "java*" -o -name "*box" -o -name "env*" -o -name ".*history" -o -name ".*profile" -o -name "ssh*" -o -name "telnet*" -o -name "mosh*" ")" >/sdcard/Download/findf-t 2>/sdcard/Download/findf-te &
argv=("$@")

findf() {
    if [ ! -L "$1" ] && [ -d "$1" ]; then
        while IFS= read -r -d '' x; do
            if [ "$x" ] && [ "$x" != "/proc" ] && [[ $x != *'/emulated/0' ]]; then
                findf "$x"
            fi
        done < <(busybox3 find "$1" -mindepth 1 -maxdepth 1 -print0)
    else # L,f,S,b,c,p
        busybox3 find "$1" "${argv[@]}"
    fi
}

findf /
echo "$(date "+%F %T") exit $?" >&2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment