0

I have just installed Oracle weblogic on rhel server. Installation went successfully however the install guide given to me to run below command without explanation. I would like to know what I am getting into.

grep -Rl jdk1.7.0_80 . | xargs sed -i s,jdk17.0_80,weblogic, 
  • jdk1.7.0_70 is installed at /usr/java/jdk1.7.0_80
  • weblogic is installed at /some/path/name and the install guide asks me to run the command within /some/path/name.
5
  • This is supposed to change the string jdk17.0_80 to weblogic in all files that contain it (under the current dir). It has nothing to do with the actual executables. The trailing comma is missing from the sed command though (and most likely, there should be a g too). Commented May 11, 2016 at 16:48
  • If you want to see what it does (sort of dry-run) simply remove the -i and run it. Commented May 11, 2016 at 16:54
  • yes, you are right trailing comma is missing. I added it back to the original post. Thank you for your explanation. i feel better what I am about to do. Commented May 11, 2016 at 16:55
  • got it! will try it! Commented May 11, 2016 at 16:55
  • Simplest way to learn about it is to put echo before the sed. Commented May 11, 2016 at 21:07

1 Answer 1

0

Breaking down what don_crissti stated:

  1. grep -Rl jdk1.7.0_80 . will search the current location (.), recursively (-R), for jdk1.7.0_80, and return the name of each file with a match (-l).
  2. | will "pipe" the output to the next command, xargs.
  3. xargs will build and execute commands from standard input (e.g. the pipe). In this case, it will build a series of sed commands from the file list returned by grep.
  4. sed -i s,jdk17.0_80,weblogic, <filename> will edit each file in place (-i) and substitute (s) according to the regular expression that follows. Note that the sed s-command documentation uses the typical regex delimiter of / but states that any character, such as , may be used.
1
  • it is very clear to me what is happening! Thank you! Commented May 11, 2016 at 21:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.