Created
August 9, 2012 01:38
-
-
Save manpages/3300224 to your computer and use it in GitHub Desktop.
ls -R for busybox
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
#!/bin/bash | |
my_lsr () { | |
d=$1; | |
for x in "$d"/* "$d"/.[!.]* "$d"/..?*; do | |
if test -f "$x"; then | |
# handler for an ordinary file | |
eval "$2" "$x" | |
elif test -h "$x"; then | |
# handler for a symlink | |
eval "$2" "$x" | |
elif test -d "$x"; then | |
# RECURSION! DO NOT ENTER! | |
my_lsr "$x" "$2" | |
fi | |
done | |
} | |
my_lsr $1 $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
04:38:39 < MagBo> I'll update it with a version for RO busyboxes in a sec
04:38:44 < MagBo> or no
04:38:44 < MagBo> nah
04:38:47 < MagBo> I'm too lazy
04:39:13 < MagBo> it seems pretty obvious how to fold that into a oneliner using exports and $d rewriting. :)