如何用sed删除特定文件行?
-
- 帖子: 8
- 注册时间: 2011-04-07 21:47
如何用sed删除特定文件行?
需要删除一个文件中行长度超过20个字符的行,请问如何用sed实现
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- tenzu
- 论坛版主
- 帖子: 36924
- 注册时间: 2008-11-21 20:26
-
- 帖子: 8
- 注册时间: 2011-04-07 21:47
Re: 如何用sed删除特定文件行?
Thanks, but it doesn't work, I used sed -i -e '/.{20,}/d' file to remove the line contains more than 20 characters, is it right?eexpress 写了:行长度超过20个字符
/.{20,}/d
Can you please express the expression?
- lilydjwg
- 论坛版主
- 帖子: 4258
- 注册时间: 2009-04-11 23:46
- 系统: Arch Linux
- 联系:
Re: 如何用sed删除特定文件行?
这个是超过20个字节的吧?那个 {} 貌似需要转义。arthurchen 写了:Thanks, but it doesn't work, I used sed -i -e '/.{20,}/d' file to remove the line contains more than 20 characters, is it right?eexpress 写了:行长度超过20个字符
/.{20,}/d
Can you please express the expression?
-
- 帖子: 8
- 注册时间: 2011-04-07 21:47
Re: 如何用sed删除特定文件行?
不用sed了, 换成awk 'length < 20' 输出小于20个字符的行, 貌似这样速度还快些
因为我的是文件全是英文字符,所以字节和字符个数是一样的
因为我的是文件全是英文字符,所以字节和字符个数是一样的
- lexdene
- 帖子: 434
- 注册时间: 2010-02-21 16:19
- 来自: 大连
- 联系:
-
- 帖子: 299
- 注册时间: 2009-07-25 19:23