我正在尝试查找列出所有文件(包括隐藏文件)的命令,但必须排除当前目录和父目录.请帮忙.
$ ls -a \.\..
Run Code Online (Sandbox Code Playgroud)
Bas*_*tch 29
阅读ls(1)文档(可能带有man ls).至少,要养成尝试的习惯
ls --help
Run Code Online (Sandbox Code Playgroud)
或更好(因为ls可能是别名,例如你的~/.bashrc)
/bin/ls --help
Run Code Online (Sandbox Code Playgroud)
你会得到一些东西:
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters
Run Code Online (Sandbox Code Playgroud)
等等....
你想要ls -A或更好/bin/ls -A(没有任何额外的参数,如.*)
$ ls -lA
Run Code Online (Sandbox Code Playgroud)
最适合我的需要。
为了方便起见,我建议在 .bashrc 文件中定义一个别名,如下所示:
alias ll='ls -lA'
Run Code Online (Sandbox Code Playgroud)