当前位置: 首页 > news >正文

[sed] replace the first line with certain info

 

If you want to use sed to replace the first line of a file with

<div id="lexicoEntryPage">

then the proper command is:

sed '1s/.*/<div id="lexicoEntryPage">/' inputfile > outputfile

Explanation:

  • 1 → applies the substitution only to line 1

  • s → means substitute

  • .* → matches the entire contents of the line

  • The replacement text is <div id="lexicoEntryPage">

  • The redirection > outputfile saves the modified result to a new file

If you want to edit the file in place (i.e., overwrite it):

sed -i '1s/.*/<div id="lexicoEntryPage">/' inputfile

⚠️ On macOS, sed -i requires an empty string argument to avoid backup creation:

sed -i '' '1s/.*/<div id="lexicoEntryPage">/' inputfile

Would you like the command to also ensure a matching closing </div> tag at the end of the file (if not already present)?

 

http://www.gsyq.cn/news/28603.html

相关文章:

  • 2025提升机/自动提升机厂家推荐垚林机械,高效稳定省心之选
  • 配置Modbus TCP转RS485模块读取温度内容
  • redis-配置优化
  • 2025发电机/发电机组/柴油发电机/甲醇发电机组租赁厂家推荐新疆泓浩机电,专业维修保养服务保障
  • leetcode_146 LRU缓存 - 详解
  • 2025 年压滤机厂家最新推荐排行榜:隔膜 / 污泥 / 真空 / 板框 / 带式压滤机优质品牌权威指南
  • 2025 年氮化硅陶瓷球生产厂家最新推荐榜:高精度高耐磨产品优选,国内优质企业全面剖析
  • 详细介绍:python(73) 引用.dll文件并调用函数
  • harbor基于自建证书部署HTTPS及k8s集群
  • Windows 命令行查看COM口
  • 【IEEE出版】第六届计算机通信与网络安全国际学术会议(CCNS 2025)
  • playwright自动化测试应用-Day1
  • 改进的(μ+λ)约束差分进化算法设计与实现
  • 2025耳机/DC/防水耳机插座厂家推荐皓富电子,专业品质保障
  • 2025年口碑好的载带成型机厂家最新权威推荐榜
  • Mac Jenkins 环境部署
  • 达梦数据库(DM)同机 异机备份到 MinIO(Java 实现 干货直给)
  • 氛围编程:IT领导者须知
  • Day22-C:\Users\Lenovo\Desktop\note\code\JavaSE\Basic\src\com\File-FileTest1~4
  • 实用指南:计算机中用8位如何计算最大值和最小值-128~127
  • 权威调研榜单:徐州CCC产品认证公共服务平台TOP3榜单好评深度解析
  • 权威调研榜单:落地立式护眼灯厂家TOP3榜单好评深度解析
  • 详细介绍:C++面向对象编程——引用
  • 2025 年道闸源头厂家最新推荐排行榜:聚焦专利技术与多场景适配的权威优选指南直杆/ 栅栏道闸/道闸停车场系统/道闸识别一体机/道闸系统公司推荐
  • 精控DRC,成就高质量IC设计精品
  • 完整教程:【uniapp】uniapp+uview-ui+mixins实现搜索+上拉加载+加载动画功能:
  • 2025 年天津老味儿刨冰最新推荐榜:精选 5 家世代传承与新兴热门品牌,附品质选择指南
  • RTX5060TI 配置Xinference
  • js函数声明和函数表达式的理解
  • P13382 解题报告