0

I have just started with BASH shell scripting journey so need help with few commands.

I need to extract particular string from "ps -ef | grep <processName>

This gives output like below:

weblogic   31761 30873  5 02:44 ?        00:10:51 /m1/appl/jdk/bin/java -d64 -Xms1024m -Xmx2700m -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/m1/appl/instance/debug -XX:FlightRecorderOptions=settings=default -XX:+UseParallelOldGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:ReservedCodeCacheSize=1024m -XX:SoftRefLRUPolicyMSPerMB=200 -XX:+ExitOnOutOfMemoryError -XX:+ParallelRefProcEnabled -XX:+PrintConcurrentLocks -XX:+DisableExplicitGC -XX:CompileThreshold=1000 -XX:MetaspaceSize=256m -XX:NewRatio=7 -XX:ParallelGCThreads=4 -XX:MaxMetaspaceSize=3072m -cp /m1/appl/fmw/wlserver/server/lib/weblogic-launcher.jar -Dlaunch.use.env.classpath=true -Dweblogic.Name=AdminServer -Djava.security.policy=/m1/appl/wlserver/server/lib/weblogic.policy -Dhttps.proxyHost=XX.XX.XX.XX -Dweblogic.heapDumpPathOnDeadlock=/m1/appl/instance/debug -Dhttps.proxySet=true 

how can I extract value of "-Dhttps.proxyHost"?

XX.XX.XX.XX

can awk and substr be useful here?

3
  • Please specify the actual shell. A programming language called "shell script" doesn't exist! As a new user heer, also take the tour and read How to Ask. Commented Jan 16, 2022 at 12:56
  • Apologies.. it's bash shell Commented Jan 16, 2022 at 13:03
  • edit your question, please! Check both the text and the tags that you applied. Commented Jan 16, 2022 at 13:11

1 Answer 1

0

Either one of these commands:

... | grep -Po '(?<=-Dhttps.proxyHost=)[^[:space:]]+'
... | awk -v RS=' ' -F = '$1 == "-Dhttps.proxyHost" { print $2 }'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.