FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 04-09-2010, 10:20 AM
Tom Brown
 
Default sed a particular line in file

I need to change a value in a file, but this line occurs more than once in this file therefore as i know the line number this value appears on how can i change that?

I thought i could use sed to change a particular line number but i dont see that in the man page, i am trying to change a value from line number 6


thanks

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 04-09-2010, 10:43 AM
Stephen Harris
 
Default sed a particular line in file

> I thought i could use sed to change a particular line number but i dont see
> that in the man page, i am trying to change a value from line number 6

% cat foo
Hello line 1
Hello line 2
Hello line 3

# To change just line 2
% sed '2s/Hello/There/'
Hello line 1
There line 2
Hello line 3

# To change line 2 and onwards
% sed '2,$s/Hello/There/'
Hello line 1
There line 2
There line 3

It's that simple :-)

--

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 04-10-2010, 08:16 AM
Tom Brown
 
Default sed a particular line in file

> % cat foo
> Hello line 1
> Hello line 2
> Hello line 3
>
> # To change just line 2
> % sed '2s/Hello/There/'
> Hello line 1
> There line 2
> Hello line 3
>
> # To change line 2 and onwards
> % sed '2,$s/Hello/There/'
> Hello line 1
> There line 2
> There line 3
>
> It's that simple :-)
>
>

yes indeed - simples

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 07:05 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org