Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

sed is not overwriting a file

$
0
0
hi

i have a file as in follwoing:

Code:

cat apple.txt
Apple is a fruit
But this fruit is costly

Now I used the sed command and i see output as in following

Code:

[root@2 ~]# sed 's/fruit/healthy &/'  fruit.txt
Apple is a healthy fruit
But this healthy fruit is costly
[root@2 ~]#

sed works fine here. But when I cat "fruit.txt" i dont see the file overwritten by the changes done by sed command. I see only old file which was existing
Code:

[root@2 ~]# sed 's/fruit/healthy &/'  fruit.txt
Apple is a healthy fruit
But this healthy fruit is costly
[root@2 ~]# cat fruit.txt
Apple is a fruit
But this fruit is costly
[root@2 ~]#

Please help :mad:

Viewing all articles
Browse latest Browse all 16232

Trending Articles