我有这个
-Xmx10240m -Xms10240m -verbose:gc -XX:+ CMSParallelRemarkEnabled -XX:+ UseParNewGC -XX:+ ScavengeBeforeFullGC -Dsun.net.inetaddr.ttl = 3600 -XX:CMSInitiatingOccupancyFraction = 70 -XX:+ UseCMSInitiatingOccupancyOnly -XX: + PrintTenuringDistribution -XX:SurvivorRatio = 6 -XX:+ UseConcMarkSweepGC -XX:+ PrintGCDetails -XX:+ PrintGCDateStamps -XX:+ PrintHeapAtGC -XX:PermSize = 512m -XX:MaxPermSize = 512m -Xloggc:/ www / logs / jboss / macys-navapp_master_prod_cellA_m01 / gc-log.txt -XX:+ HeapDumpOnOutOfMemoryError -XX:HeapDumpPath = / www / logs / heapdump / navapp_master_prod_cellA__m01 / navapp_master_prod_cellA_m01.hprof -Djava.net.preferIPv4Stack = true -Dorg.jboss.resolver.warning = true - Djboss.modules.system.pkgs = org.jboss.byteman -Djava.awt.headless = true -XX:+ UseCompressedOops -Dclient.encoding.override = ISO-8859-1 -XX:+ DisableExplicitGC -Dorg.apache.jasper。 Constants.USE_INSTANCE_MANAGER_FOR_TAGS = false -Dorg.apache.jasper.Constants.USE_INSTANCE_MANAGER -Dorg.apache.jasper.runtime.JspFactoryImpl.USE_POOL = false -Dorg.apache.j asper.runtime.BodyContentImpl.LIMIT_BUFFER = true -XX:NewSize = 3072m -XX:MaxNewSize = 3072m -agentpath:/www/a/apps/dynatrace/dt.so=name=server1_ProdCellA_master_m1,server=ct_collector:9998 -Dfile.encoding = ISO-8859-1 -Dsdp.configuration.home = / www / apps / properties -XX:+ UseLargePages -Dzookeeper.sasl.client = false
我希望能够在匹配“-agentpath”“-agentpath:/www/a/apps/dynatrace/dt.so=name=server1_ProdCellA_master_m1,server=ct_collector:9998”
这是我正在使用的当前命令,但它不起作用“cat cached_java_opts | awk'/ -agentpath / {print $(NF)}'”
谢谢你
答案 0 :(得分:1)
像这样启动grep
:
grep -o '\-agentpath[^ ]*' yourfile
-o
选项仅打印匹配的模式(不匹配的行)。由于模式配置为扩展到第一个空格,因此您将获得整个参数(这是有效的,因为它不是命令行的最后一个参数)。也许可以使用grep -oE '\-agentpath([^ ]*|.*$)'
答案 1 :(得分:1)
cell.distanceSet(19.0)
解决方案:
awk
awk -F'-agentpath:' '{split($2,a," ") ;print FS a[1]}' infile
-agentpath:/www/a/apps/dynatrace/dt.so=name=server1_ProdCellA_master_m1,server=ct_collector:9998
:或多或少,与已经回答的相同。
grep