Linux下awk命令的使用

本节知识:

实操:

(1)打印"开始",打印每行,打印"结束":awk 'BEGIN{print "开始"}{print "结束"}' 1.txt

(2)打印每行的行号:awk '{print NR}' 1.txt

(3)打印每行的文本:awk '{print $0}' 1.txt

(4)打印每行的第1列(默认用空格分离):awk '{print $1}' 1.txt

(5)打印每行的最后1列(默认用空格分离):awk '{print $NF}' 1.txt

(6)打印每行的倒数第2列(默认用空格分离):awk '{print $(NF-1)}' 1.txt

(7)打印每行,并为每行带上行号:awk '{print NR":",$0}' 1.txt

相关推荐
用户23678298016828 分钟前
Linux systemctl 服务管理命令:从 systemd 架构到实战技巧
linux
LIZHUOLONG11 小时前
linux 设备初始化
linux·运维·服务器
雪霁清寒1 小时前
麒麟V10用MobaXterm远程连接SSH偶尔卡顿的问题
linux·ssh
ylscode1 小时前
Linux CIFSwitch 内核新漏洞允许攻击者获得 root 权限
linux·运维·服务器
诸葛务农2 小时前
共沸脱水技术及其在光刻胶用PGMEA纯化中的应用(中)
linux·数据库·人工智能
lld9510272 小时前
(二)从验证到执行:策略实时运行全链路
linux·服务器·数据库
坤昱2 小时前
cfs调度类深入解刨——最新内核细节分析5
linux·分布式·cfs调度·eevdf调度·linux调度·linux技术·kernel最新版本内容
阿洛学长3 小时前
Kali Linux 虚拟机安装(VMware Workstation 17)
java·linux·服务器
H Journey3 小时前
source命令、.bashrc 、.bash_profile、/etc/profile配置文件详解
linux·.bashrc
上天_去_做颗惺星 EVE_BLUE3 小时前
Ubuntu Android 虚拟机安装使用教程
android·linux·测试工具·ubuntu·安卓