我可以通过此命令成功检索目录名称
ls -d */
但我不能只显示我设备上的文件。
答案 0 :(得分:3)
您可以使用命令ls -l | grep ^-
以下是ls
命令的完整列表选项。
Option Description
-a Displays all files.
-b Displays nonprinting characters in octal.
-c Displays files by file timestamp.
-C Displays files in a columnar format (default)
-d Displays only directories.
-f Interprets each name as a directory, not a file.
-F Flags filenames.
-g Displays the long format listing, but exclude the owner name.
-i Displays the inode for each file.
-l Displays the long format listing.
-L Displays the file or directory referenced by a symbolic link.
-m Displays the names as a comma-separated list.
-n Displays the long format listing, with GID and UID numbers.
-o Displays the long format listing, but excludes group name.
-p Displays directories with /
-q Displays all nonprinting characters as ?
-r Displays files in reverse order.
-R Displays subdirectories as well.
-t Displays newest files first. (based on timestamp)
-u Displays files by the file access time.
-x Displays files as rows across the screen.
-1 Displays each entry on a line.
答案 1 :(得分:0)
如果您的Android设备中有sed
二进制文件,请执行以下操作:
ls -l | sed '/^d/ d'
它将从d
(Source)的输出中删除以ls -l
开头的所有行。为什么?因为输出中的所有目录都以d
开头,所以删除它们只会得到文件名。
如果Android中没有sed
,那么您可以adb pull
将文件导入PC(已保存的ls -l
输出),然后进行处理(仅适用于Linux PC):
cat <YOUR_FILE> | sed '/^d/ d'