Find and Replace in multiple Files

This is the Linux CLI-Command Line Interface command to Find all the occurrences of a string and Replace it with desired string in all the files in the directory.  This is very powerful and very fast.  So do take all the precautions before executing this command. The command is

grep -rl STRING1 SOMEDIR/ | xargs sed -i 's/STRING1/STRING2/g'

Explanation: The grep will search for the string 'STRING1' and pipe it to the sed command for the replacements.  The sed command replaces the STRING1 with STRING2  in all the occurrences of the STRING1.

YUM to download packages without installing

Command to download packages without installing….

  • Install the package including “downloadonly” plugin:
  • # yum install yum-downloadonly
  • Run yum command with “–downloadonly” option as follows:
  • # yum install –downloadonly –downloaddir=

Yumdownloader command can used for downloading the installed packages

  • Install the yum-utils package:
  • # yum install yum-utils
  • Run the command followed by the desired package:
  • # yumdownloader