Linux文件内容显示(查找丶过滤丶搜索)

本文介绍了如何在Linux系统中利用cat、sed等命令查看、过滤和搜索文件内容。例如,通过cat命令查看特定行,使用sed进行行内容筛选,以及对以':'分隔的内容进行处理,如按字母逆序排列并写入文件,统计行数等。
摘要由CSDN通过智能技术生成

 1.(1)我们通过cat 命令查看到/etc/passwd 文件第六行内容是: 6    sync:x:5:0:sync:/sbin:/bin/sync

通过sed直接查看指定行内容:

[root@server ~]# sed -n '6p' /etc/passwd
sync:x:5:0:sync:/sbin:/bin/sync

        (2)我们首先经过简单过滤过滤出包含SELINUX的行:

[root@server ~]# grep -i selinux /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
SELINUXTYPE=targeted

再次过滤出以SELNUX开头的行:

[root@server ~]# grep "^SELINUX" /etc/se
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值