与LS和grep特定扩展名的文件列表 [英] List files with certain extensions with ls and grep

查看:151
本文介绍了与LS和grep特定扩展名的文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想从当前目录,只输出.MP4 .MP3 .exe文件没有别的获取的文件。
所以我想我可以做到这一点:

I just want to get the files from the current dir and only output .mp4 .mp3 .exe files nothing else. So I thought I could just do this:

ls | grep \.mp4$ | grep \.mp3$ | grep \.exe$

不过没有关系,作为第一个grep的将输出的MP4刚的为此其他2 grep的公司将不会被使用。

But no, as the first grep will output just mp4's therefor the other 2 grep's won't be used.

任何想法? PS,运行在慢豹这个脚本。

Any ideas? PS, Running this script on Slow Leopard.

推荐答案

为什么不:

ls *.{mp3,exe,mp4}

我不知道在那里我学会了它 - 但我一直在使用这种

I'm not sure where I learned it - but I've been using this.

这篇关于与LS和grep特定扩展名的文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆