使用ls列出所有与模式不匹配的文件
Possible Duplicate:
How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?
我已经阅读了ls
的man
页,但找不到列出与文件选择器不匹配的所有选项.您知道如何执行此操作吗?
I've read the man
page for ls
, and I can't find the option to list all that do not match the file selector. Do you know how to perform this operation?
例如: 可以说我的目录是这样的:
For example: lets say my directory is this:
> ls
a.txt b.mkv c.txt d.mp3 e.flv
现在我想做些能做的事
> ls -[SOME_OPTION] *.txt
b.mkv d.mp3 e.flv
有这样的选择吗?
如果没有,是否有办法将ls
的输出传递到另一个仅显示我想要的功能的函数(可能是sed
)?
If not, is there a way to pipe the output of ls
to another function (possibly sed
) that shows only the ones that I would like?
我不知道该怎么做,但是我正在想像这样:
I don't know exactly how to do this, but I'm imagining it would be something like:
> ls | sed [SOMETHING]
我确实应该学习如何使用sed
,awk
和grep
,但是我一直陷于理解如何编写正则表达式的困境.我清楚地了解了正则表达式的概念,但是我对使用不同语法的正则表达式感到困惑.
I really should learn how to use sed
,awk
,and grep
, but I keep getting stuck at understanding how to write the regexes. I understand the concept of regular expressions clearly, but I get confused between regexes that use different syntax.
任何帮助将不胜感激!
我忘了提到我正在运行Mac OS X,因此这些功能可能与针对unix/linux shell的其他答案中讨论的功能稍有不同(因此,我对sed
,awk
,和grep
).
I forgot to mention that I am running Mac OS X, so the functions may be slightly different from the ones discussed in other answers for the unix/linux shell (hence some of my confusion with sed
,awk
,and grep
).
也许此命令会为您提供帮助
maybe this command will help you
find ./ -maxdepth 1 ! -path "*txt"