仅显示 tcsh 或 bash 中符号链接的文件和文件夹
基本上我想执行以下操作:(
ls -l[+someflags]
或通过其他方式)仅显示符号链接的文件
,以便输出看起来
-rw-r--r-- 1 username grp size date-time filename -> somedir
-rw-r--r-- 1 username grp size date-time filename2 -> somsdfsdf
等。
例如,
仅显示我有别名的目录:
alias lsd 'ls -l | grep ^d'
我想知道如何仅显示隐藏文件或者只有隐藏目录?
我有以下解决方案,但是它不以颜色显示输出:(
ls -ltra | grep '\->'
Basically I want do the following:
ls -l[+someflags]
(or by some other means) that will only display files that are symbolic links
so the output would look
-rw-r--r-- 1 username grp size date-time filename -> somedir
-rw-r--r-- 1 username grp size date-time filename2 -> somsdfsdf
etc.
For example,
to show only directories I have an alias:
alias lsd 'ls -l | grep ^d'
I wonder how to display only hidden files or only hidden directories?
I have the following solution, however it doesn't display the output in color :(
ls -ltra | grep '\->'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
查找目录中的所有符号链接:
对于隐藏文件的列表:
Find all the symbolic links in a directory:
For the listing of hidden files:
仅对于“隐藏”文件夹 - 点文件夹,请尝试:
是的,两个星号是必要的,否则您也会得到 .和..在结果中。
对于符号链接,请尝试使用符号链接程序:(
显示当前目录下的所有符号链接)
For only "hidden" folders - dot folders, try:
Yes, the two asterisks are necessary, otherwise you'll also get . and .. in the results.
For symlinks, well, try the symlinks program:
(shows all symlinks under current directory)
仅显示符号链接(文件和目录)。但不知道如何让它们变得丰富多彩。
仅显示隐藏文件/目录
仅显示目录。
shows only symlinks (files and directories). Not sure how to get them colorful, though.
shows only hidden files/directories
shows directories only.
仅显示符号链接及其链接到的内容:
限制为仅此目录
示例输出(在 ln -s /usr/bin moo 之后):
To display JUST the symlinks and what they link to:
To limit to JUST THIS DIR
Example output (after ln -s /usr/bin moo):
您的 grep 解决方案就快完成了;让我们专注于让您再次获得色彩。
试试这个:
You were almost there with your grep solution; let's focus on getting you COLOR again.
Try this:
对 @ChristopheD 给出的接受的答案进行一些改进(由于我没有足够的声誉,因此无法对接受的答案发表评论)
我使用别名,
其中别名为
Improving a little on the accepted answer given by @ChristopheD (coudnt comment on the accepted answer since I dont have enough reputation)
I use an alias
where the alias is
尝试文件类型标志并去掉附加的@
Try file type flag and get rid of the appending @
对于 (t)csh:(
这只是 pbr 的答案,但连字符已转义。)
Mac OSX
在 OSX 上,
ls
的工作方式不同,因此将其添加到您的~/.cshrc
文件中:然后调用:
For (t)csh:
(This is simply pbr's answer but with the hyphen escaped.)
Mac OSX
On OSX,
ls
works differently, so add this to your~/.cshrc
file:And then call:
对于 bash:
这提供了很好的输出。
For bash:
This provides a nice output.
用法: foo $path
如果未指定,则使用当前路径。
Usage: foo $path
Uses current path if none specified.