---
title: "linux 修改文件中某一行"
author: "wushexin"
date: "2011-04-27T18:21:56Z"
tags: ["Linux"]
categories: ["操作系统"]
slug: "linux"
draft: false
lastmod: "2011-04-27T18:21:56Z"
id: 1020309
url: "https://wushexin.iteye.com/blog/1020309"
---

```
sed -i  "1s/oldstr/newstr/" filename

示例：
config文件：

[wusx@centos245 gather]$ cat config 
start=359822
end=550000
threads=15
output=/home/wusx/gather/output
log=/home/wusx/gather/_wget.log

#将当前下的文档序列，写回config文件。
sed -i "1s/start=$(($i-1))/start=$i/" /home/wusx/gather/config
```