小编ale*_*erm的帖子

grep和awk,结合命令?

我有看起来像的文件:

This is a RESTRICTED site.
All connections are monitored and recorded.
Disconnect IMMEDIATELY if you are not an authorized user!
sftp> cd outbox
sftp> ls -ltr
-rw-------   1 0        0            1911 Jun 12 20:40 61N0584832_EDIP000749728818_MFC_20190612203409.txt
-rw-------   1 0        0            1878 Jun 13 06:01 613577165_EDIP000750181517_MFC_20190613055207.txt
Run Code Online (Sandbox Code Playgroud)

我只想在一个命令中打印.txt文件名。

我可以:

grep -e '^-' outfile.log > outfile.log2
Run Code Online (Sandbox Code Playgroud)

..仅给出以“-”开头的行。

-rw-------   1 0        0            1911 Jun 12 20:40 61N0584832_EDIP000749728818_MFC_20190612203409.txt
-rw-------   1 0        0            1878 Jun 13 06:01 613577165_EDIP000750181517_MFC_20190613055207.txt

Run Code Online (Sandbox Code Playgroud)

然后:

awk '{print $9}' outfile.log2 > outfile.log3
Run Code Online (Sandbox Code Playgroud)

..给出所需的输出: …

unix awk grep

2
推荐指数
1
解决办法
78
查看次数

标签 统计

awk ×1

grep ×1

unix ×1