awk与sed的基本使用

没有# /等特殊字符 sed -i '1s/.*/好好好好好好/' /root/123.txt

有# /等特殊字符 sed -i '1s@.*@#!/usr/bin/python02@' /root/123.txt

如果都有则边界只能使用转义符号 "\"


只覆盖替换123.txt文本的第一行内容(好好好好好好) sed -i '1s/.*/好好好好好好/' /root/123.txt

只覆盖替换123.txt文本的第16行内容(好好好好好2) sed -i '16s/.*/好好好好好好/' /root/123.txt

只覆盖替换123.txt文本的每一行内容(好好好好好2) sed -i 's/.*/好好好好好好/' /root/123.txt

打印整个文本 awk '{print ; next} 1' /root/123.txt

打印第一行 awk '{if (NR==1) print ; next} 1' /root/123.txt

打印整个文本且每一行都替换为hello输出(输出的都是hello) awk '1 {print "Hello World"}' /root/123.txt

相关推荐
今天也想MK代码1 小时前
数据模型与持久化存储
linux·运维·ubuntu
水天需0101 小时前
Vim 搜索和替换详解
linux
乔碧萝成都分萝1 小时前
十六、一个基本的GPIO驱动程序
linux·驱动开发·嵌入式
ModestCoder_1 小时前
Ubuntu 22.04,Isaac Sim 5.1.0 + Isaac Lab 2.3.0 Conda 环境安装指南
linux·ubuntu·conda
水天需0101 小时前
Vim 学习全面指南
linux
9ilk1 小时前
【Linux】--- 多路转接select / poll / epoll
linux·运维·网络
jason成都1 小时前
emqx的docker部署
运维·docker·容器
赖small强1 小时前
【Linux驱动开发】Linux 中断机制深度解析:原理、监控与实战
linux·中断·硬件中断
buyutang_1 小时前
Linux 网络编程:TCP协议Socket开发全流程,理解多线程多进程实现的多连接网络通讯模型
linux·网络·tcp/ip