linux - 如何使用 sed 更改日志文件的输出

标签 linux logging sed output

我有一个日志文件的以下输出

/var/www/user/data/www/domain.com/wp-config.php
/var/www/anotheruser/data/www/otherdomain.com/wp-config.php

我正在尝试获得这样的输出:

domain.com
otherdomain.com

我只知道如何删除 /wp-config.php,但我不知道如何删除 domain.com 之前的所有内容。

问题是它们都是不同的

最佳答案

试试这个:

awk -F'/' 'NF{print $(NF-1)}' log

关于linux - 如何使用 sed 更改日志文件的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19927113/

相关文章:

tomcat - 在 JEE/Tomcat 应用程序中,使用 java.util.logging 部署到 OpenShift,如何在运行时更改日志记录级别?

parsing - PostgreSQL 对极短查询的解析异常缓慢

linux - sed 未终止 's' 命令

linux - sudo "-u"选项不起作用

linux - UNIX(或LINUX)中的退出和等待函数

c++ - 如何在 Linux 中将 OpenCV 添加到 LD_LIBRARY_path?

amazon-web-services - 将日志转发到 Cloudwatch Logs

linux - 我如何在 Linux 中创建多级软链接(soft link)或者可以这样做吗?

linux - 如何打印前n列和与模式匹配的列?

linux - 使用 sed 从文件中删除连续的特殊字符