pan*_*ear 4 linux bash grep gnu
我有一个目录,其中包含一堆带有数字文件名的文件.它们没有前导零,所以如果我grep hello *在该目录中执行类似的操作,我可能会得到类似这样的内容:
22:hello, world!
6:hello
62:"Say hello to them for me."
Run Code Online (Sandbox Code Playgroud)
我宁愿让结果像这样:
6:hello
22:hello, world!
62:"Say hello to them for me."
Run Code Online (Sandbox Code Playgroud)
发生在我身上的第一个想法是用数字方式对结果进行排序,grep hello * | sort -n但后来我失去了grep的颜色,我想保留它.最好的方法是什么?
ls * | sort -n | xargs -d '\n' grep hello
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6351 次 |
| 最近记录: |