sed/awk 문자열 삭제

sed/awk 문자열 삭제

다음 정보가 포함된 txt 파일이 있습니다.

-Xmx4096m -Xms4096m -verbose:gc -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+ScavengeBeforeFullGC -Dsun.net.inetaddr.ttl=3600 -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSInitiatingOccupancyOnly -XX:+PrintTenuringDistribution -XX:SurvivorRatio=6 -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:PermSize=256m -XX:MaxPermSize=256m -Xloggc:/www/logs/jboss/macys-navapp_master_mcomnavapp_m01/gc-log.txt -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/www/logs/heapdump/macys-navapp_master_mcomnavapp_m01/macys-navapp_master_mcomnavapp_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 -Dfile.encoding=ISO-8859-1 -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.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dsdp.configuration.home=/www/apps/properties -Dzookeeper.sasl.client=false -agentpath:/www/apps/dynatrace/dynatrace_apm/agent/lib64/libdtagent.so=name=agent_name,collector=dtcoldev_new:9998 XX:MaxPermSize=256m -Xloggc:/www/logs/jboss/macys-navapp_master_mcomnavapp_m01/gc-log.txt -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/www/logs/heapdump/macys-navapp_master_mcomnavapp_m01/macys-navapp_master_mcomnavapp_m01.hprof -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true

문자열 내용만 삭제 -agentpath:/www/apps/dynatrace/dynatrace_apm/agent/lib64/libdtagent.so=name=agent_name,collector=dtcoldev_new:9998하고 그 이후에는 아무것도 삭제하고 싶지 않습니다.

현재 내가 사용하고 있는

sed 's/-agentpath.*//' -i files

agentpath위의 문자열 삭제를 제한하는 방법은 무엇 입니까 ?

답변1

*공백이 아닌 문자로 제한 :

sed -i 's/-agentpath[^ ]*//' files

관련 정보