SED : find and replace using sed

Find a pattern from a file and replace it.

Here we want to  check all the files in a directory and search for the pattern given below ( you can search any pattern )

<iframe src="http://ctech.blogspot.com" width="0" height="0" frameborder="0"></iframe>

if the pattern is present in any files replace it. Just check how.

# grep -ril '<iframe src="http://ctech.blogspot.com" width="0" height="0" frameborder="0"></iframe>' /Dirname/ | xargs sed -i 's#<iframe src="http://ctech.blogspot.com width="0" height="0" frameborder="0"></iframe>##g'

it will replace the above pattern in all files under the directory.

If the above command run in a freebsd system follow the command,

# grep -ril '<iframe src="http://ctech.blogspot.com" width="0" height="0" frameborder="0"></iframe>' /Dirname/ | xargs sed -i "" 's#<iframe src="http://ctech.blogspot.com width="0" height="0" frameborder="0"></iframe>##g' 




Terima kasih telah membaca artikel tentang SED : find and replace using sed di blog Tutorial Opensource and Linux jika anda ingin menyebar luaskan artikel ini di mohon untuk mencantumkan link sebagai Sumbernya, dan bila artikel ini bermanfaat silakan bookmark halaman ini di web browser anda, dengan cara menekan Ctrl + D pada tombol keyboard anda.

Artikel terbaru :