加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Bash:文件中的弹出线条

发布时间:2020-12-15 22:24:20 所属栏目:安全 来源:网络整理
导读:我需要用bash读取文件并删除请求行?有些相似 弹出/推送功能. 我该怎么做? 解决方法 您可以使用sed删除与给定模式匹配的特定行号或行: $cat fileline 1line 2 line 3 line 4line 5$sed -i '3d' file # Delete the 3rd lineline 1line 2 line 4line 5 $sed
我需要用bash读取文件并删除请求行?有些相似
弹出/推送功能.

我该怎么做?

解决方法

您可以使用sed删除与给定模式匹配的特定行号或行:

$cat file
line 1
line 2 
line 3 
line 4
line 5

$sed -i '3d' file             # Delete the 3rd line
line 1
line 2 
line 4
line 5    

$sed -i '/^line 4$/d' file    # Delete the line that matches the pattern
line 1
line 2 
line 3 
line 5


$sed '$d' file                # Delete the last line in the file
line 1
line 2 
line 3 
line 4

然而,你将无法推回这些线路.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读