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

相关推荐
哈基咪怎么可能是AI4 小时前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行20 小时前
Linux和window共享文件夹
linux
Sinclair1 天前
简单几步,安卓手机秒变服务器,安装 CMS 程序
android·服务器
木心月转码ing1 天前
WSL+Cpp开发环境配置
linux
Rockbean2 天前
用40行代码搭建自己的无服务器OCR
服务器·python·deepseek
蝎子莱莱爱打怪2 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
茶杯梦轩2 天前
CompletableFuture 在 项目实战 中 创建异步任务 的核心优势及使用场景
服务器·后端·面试
崔小汤呀2 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端
何中应2 天前
vi编辑器使用
linux·后端·操作系统
何中应2 天前
Linux进程无法被kill
linux·后端·操作系统