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 :

  • How To Install Cinnamon In Ubuntu 14.04
  • How To Install Mate Desktop In Ubuntu 14.04
  • Creating the first Windows Server 2003 Domain Controller in a domain
  • How To Install Ubuntu 13.10 Server
  • How to Install Nuvola Player in Ubuntu
  • How to establish Emerald in Ubuntu 13.10 & Linux Mint 16
  • How to Restoring iptables Automatically On Boot on Debian and Ubuntu
  • How to Compile FFMPEG with H.264 and LAME in Ubuntu And Debian
  • How to Install Linux on a Playstation 2
  • apt-fast: Improve apt-get Download Speed
  • Artikel terkait :