Skip to content

Instantly share code, notes, and snippets.

@manpages
Created August 9, 2012 01:38
Show Gist options
  • Save manpages/3300224 to your computer and use it in GitHub Desktop.
Save manpages/3300224 to your computer and use it in GitHub Desktop.
ls -R for busybox
#!/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
@manpages
Copy link
Author

manpages commented Aug 9, 2012

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. :)

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