If im not mistaking, using ls -b
should output escape characters with some sort of representation, but it seems like this option isn't available. Is there an alternative, or is it impossible to have a filename with escape characters on android?
Android has a very limited implementation of Linux shell functions. BusyBox utility expands on the selection somewhat, although it's still not a full Linux set. It can be installed on most rooted Android devices.
Specifically for ls
, only the following options are available via BusyBox:
busybox: invalid option -- b
BusyBox v1.22.1 bionic (2014-05-29 17:30 +0200) multi-call binary.
Usage: ls [-1AaCxdLHRFplinsehrSXvctukKZ] [-w WIDTH] [FILE]...
List directory contents
-1 One column output
-a Include entries which start with .
-A Like -a, but exclude . and ..
-C List by columns
-x List by lines
-d List directory entries instead of contents
-L Follow symlinks
-H Follow symlinks on command line
-R Recurse
-p Append / to dir entries
-F Append indicator (one of */=@|) to entries
-l Long listing format
-i List inode numbers
-n List numeric UIDs and GIDs instead of names
-s List allocated blocks
-e List full date and time
-h List sizes in human readable format (1K 243M 2G)
-r Sort in reverse order
-S Sort by size
-X Sort by extension
-v Sort by version
-c With -l: sort by ctime
-t With -l: sort by mtime
-u With -l: sort by atime
-k List security context
-K List security context in long format
-Z List security context and permission
-w N Assume the terminal is N columns wide
--color[={always,never,auto}] Control coloring
The characters allowed in file names on Android are no different from those allowed in other Linux-based systems. As always, it depends on the filesystem.
-
1It's worth being extra-clear that this list isn't the list of options that work in the stock
ls
, which is even more limited. – Dan Hulme Jun 13 '14 at 16:29 -
thanks, so it seems that if my filename has some escape character or something of that sort, there is no way to pull it with ls without possibly losing information, or is there a way using adb to handle these cases? – Moshe Magnes Jun 13 '14 at 18:08
You can use wild card characters for these cases. Use * for multiple characters and ? for single characters. ls lib* will find files that begin with lib.
-
That's good advice, but typing the escapes isn't the problem: it's what happens when
ls
tries to print them to the terminal. – Dan Hulme Jun 15 '14 at 9:33
ls
. – ctt Jun 17 '14 at 23:29