Replacing a string in a file

Replacing a string in a file

Post by Subhro S » Tue, 02 Apr 1996 04:00:00



In a file, how could I replace certain strings with others
from the command line?

I.e., I want to replace all instances of "On since" in a file with
"Last login"

I am using ksh.

Thanks!
--

http://www.eecs.nwu.edu/~sksen/                northwestern university
                                                    evanston, illinois

--

http://www.eecs.nwu.edu/~sksen/                northwestern university
                                                    evanston, illinois

 
 
 

Replacing a string in a file

Post by Alan H. Ka » Tue, 02 Apr 1996 04:00:00



> I.e., I want to replace all instances of "On since" in a file with
> "Last login"

Use sed.

sed 's/On since/Last login/' filename > new_filename

You can then mv new_filename filename

--
Alan H. Katz          | MJ Research, Inc.

617-370-8128          | Watertown, MA 02172
                      |

 
 
 

Replacing a string in a file

Post by Kurt J Lan » Wed, 17 Apr 1996 04:00:00



>In a file, how could I replace certain strings with others
>from the command line?
>I.e., I want to replace all instances of "On since" in a file with
>"Last login"
>I am using ksh.
>Thanks!
>--

>http://www.eecs.nwu.edu/~sksen/                northwestern university
>                                                    evanston, illinois
>--

>http://www.eecs.nwu.edu/~sksen/                northwestern university
>                                                    evanston, illinois

man sed. Hope this helps.
--
--