Replace contents of a file
Hi,
I want to replace the contents of a file.I tried using : sed 's/01514581/01514582/' $p where 01514581 is the original value 01514582 is the replaced value $p is the file name (captured in a variable).. The output does not recognise $p If you give : sed 's/01514581/01514582/' test where 'test' is the filename then the output is not getting saved into the file 'test'.. Kindly let me know how i can do this. Thanks |
Quote:
Create a copy of test, use the copy as input to sed, and send the modified stream to test. Code:
$ cp test test.original Quote:
Code:
$ p="test" |
Quote:
Quote:
1. $ sed 's/01514581/01514582/' test >/tmp/test.tmp $ mv /tmp/test.tmp test 2. perl -pi -e 's/01514581/01514582/' test Hope this works. |
Quote:
|
All times are GMT -5. The time now is 09:06 AM. |