<kernel>use_profile 0use_group 0file execute /lib64/rc/sh/cgroup-release-agent.sh exec.realpath=/lib64/rc/sh/cgroup-release-agent.sh exec.argv[0]=/lib64/rc/sh/cgroup-release-agent.shfile execute /sbin/init exec.realpath=/sbin/init exec.argv[0]=/sbin/initfile execute /sbin/modprobe exec.realpath=/bin/kmod exec.argv[0]=/sbin/modprobe<kernel> /sbin/inituse_profile 0use_group 0<kernel> /sbin/init /sbin/openrcuse_profile 0use_group 0<kernel> /sbin/init /sbin/openrc /lib64/rc/sh/init-early.shuse_profile 0use_group 0<kernel> /etc/init.d/dmesguse_profile 0use_group 0file execute /lib64/rc/sh/openrc-run.sh exec.realpath=/lib64/rc/sh/openrc-run.sh exec.argv[0]=/lib64/rc/sh/openrc-run.shfile read /etc/rc.conffile read /run/openrc/depconfigfile read /run/openrc/deptreefile read /sbin/openrc-runfile read proc:/cmdlinefile symlink /run/openrc/started/dmesg symlink.target=/etc/init.d/dmesgfile symlink /run/openrc/starting/dmesg symlink.target=/etc/init.d/dmesgfile unlink /run/openrc/exclusive/dmesgfile unlink /run/openrc/starting/dmesgmisc env CONFIG_PROTECTmisc env CONFIG_PROTECT_MASKmisc env DCC_EMAILLOG_WHOM_TO_BLAMEmisc env DISTCC_ENABLE_DISCREPANCY_EMAILmisc env DISTCC_FALLBACKmisc env DISTCC_SAVE_TEMPSmisc env DISTCC_SSHmisc env DISTCC_TCP_CORKmisc env DISTCC_VERBOSEmisc env EINFO_LOGmisc env GCC_SPECSmisc env GSETTINGS_BACKENDmisc env GUILE_LOAD_PATHmisc env INFOPATHmisc env LANGmisc env LESSmisc env LESSOPENmisc env MANPAGERmisc env MANPATHmisc env OPENCL_PROFILEmisc env OPENGL_PROFILEmisc env PATHmisc env QT_GRAPHICSSYSTEMmisc env RC_BOOTLEVELmisc env RC_DEFAULTLEVELmisc env RC_LIBEXECDIRmisc env RC_PIDmisc env RC_RUNLEVELmisc env RC_SVCDIRmisc env RC_TMPDIRmisc env RC_UNAMEmisc env RC_VERSIONmisc env ROOTPATHmisc env TERMmisc env UNCACHED_ERR_FDmisc env VBOX_APP_HOMEmisc env XDG_CONFIG_DIRSmisc env XDG_DATA_DIRSmisc env XSESSION<kernel> /usr/sbin/ntpdateuse_profile 3use_group 0misc env LS_COLORSmisc env LANGmisc env DISPLAYmisc env LC_CTYPEmisc env TERMmisc env XAUTHORITYmisc env PATHmisc env COLORTERMmisc env MAILmisc env LOGNAMEmisc env USERmisc env USERNAMEmisc env HOMEmisc env SHELLmisc env SUDO_COMMANDmisc env SUDO_USERmisc env SUDO_UIDmisc env SUDO_GIDnetwork unix dgram send /dev/logfile read /etc/nsswitch.conffile read /etc/servicesfile read /etc/host.conffile read /etc/resolv.conffile read /etc/hostsnetwork inet dgram send 127.0.0.1 53file ioctl socket:[family=2:type=2:protocol=17] 0x541Bfile read /etc/gai.confnetwork inet dgram bind/send :: 123network inet dgram bind/send 0.0.0.0 123<kernel> /sbin/init /sbin/openrc /lib64/rc/sh/init-early.sh /usr/bin/loadkeysuse_profile 0use_group 0<kernel> /sbin/init /sbin/openrc /lib64/rc/sh/init.shuse_profile 0use_group 0<kernel> /etc/init.d/ntpduse_profile 3use_group 0misc env LS_COLORSmisc env LANGmisc env DISPLAYmisc env LC_CTYPEmisc env TERMmisc env XAUTHORITYmisc env PATHmisc env COLORTERMmisc env MAILmisc env LOGNAMEmisc env USERmisc env USERNAMEmisc env HOMEmisc env SHELLmisc env SUDO_COMMANDmisc env SUDO_USERmisc env SUDO_UIDmisc env SUDO_GIDfile read /sbin/openrc-runfile read /etc/rc.conffile read proc:/cmdlinefile read /etc/profile.envfile read proc:/cpuinfofile read proc:/1/environfile read /run/openrc/softlevelfile create /run/openrc/exclusive/ntpd 0664file write/unlink /run/openrc/exclusive/ntpdfile symlink /run/openrc/starting/ntpd symlink.target=/etc/init.d/ntpdfile read /run/openrc/depconfigfile read /run/openrc/deptreefile execute /lib64/rc/sh/openrc-run.sh exec.realpath=/lib64/rc/sh/openrc-run.sh exec.argv[0]=/lib64/rc/sh/openrc-run.shmisc env CONFIG_PROTECTmisc env CONFIG_PROTECT_MASKmisc env GCC_SPECSmisc env GSETTINGS_BACKENDmisc env INFOPATHmisc env LESSmisc env LESSOPENmisc env MANPAGERmisc env MANPATHmisc env OPENGL_PROFILEmisc env QT_GRAPHICSSYSTEMmisc env ROOTPATHmisc env VBOX_APP_HOMEmisc env XDG_CONFIG_DIRSmisc env XDG_DATA_DIRSmisc env RC_VERSIONmisc env RC_LIBEXECDIRmisc env RC_SVCDIRmisc env RC_TMPDIRmisc env RC_BOOTLEVELmisc env RC_RUNLEVELmisc env RC_DEFAULTLEVELmisc env RC_UNAMEmisc env EINFO_LOGmisc env RC_SVCNAMEmisc env RC_OPENRC_PIDmisc env RC_RUNSCRIPT_PIDmisc env RC_CMDfile read /bin/bashfile read/write /dev/ttyfile read /usr/lib64/locale/locale-archivefile read /etc/nsswitch.conffile read /etc/passwdfile ioctl devpts:/3 0x540Ffile read /lib64/rc/sh/openrc-run.shfile read /lib64/rc/sh/functions.shfile execute /lib64/rc/bin/eval_ecolors exec.realpath=/lib64/rc/bin/eval_ecolors exec.argv[0]=eval_ecolorsmisc env PWDmisc env SHLVLmisc env _file read /usr/share/terminfo/r/rxvt-unicode-256colorfile ioctl devpts:/3 0x5413file read /lib64/rc/sh/rc-functions.shfile read /lib64/rc/sh/rc-cgroup.shfile read /etc/conf.d/ntpdfile read /lib64/rc/sh/runit.shfile read /lib64/rc/sh/s6.shfile read /lib64/rc/sh/start-stop-daemon.shfile read /lib64/rc/sh/supervise-daemon.shfile write/truncate /sys/fs/cgroup/cpu/tasksfile write/truncate /sys/fs/cgroup/cpuacct/tasksfile write/truncate /sys/fs/cgroup/cpuset/tasksfile write/truncate /sys/fs/cgroup/freezer/tasksfile write/truncate /sys/fs/cgroup/memory/tasksfile write/truncate /sys/fs/cgroup/openrc/tasksfile execute /bin/mkdir exec.realpath=/bin/mkdir exec.argv[0]=mkdirmisc env RC_SERVICEmisc env SVCNAMEfile mkdir /sys/fs/cgroup/openrc/ntpd/ 0700file write/truncate /sys/fs/cgroup/openrc/ntpd/tasksfile read /etc/init.d/ntpdfile execute /lib64/rc/bin/ebegin exec.realpath=/lib64/rc/bin/ebegin exec.argv[0]=ebeginfile execute /sbin/start-stop-daemon exec.realpath=/sbin/start-stop-daemon exec.argv[0]=start-stop-daemonfile read/write /dev/nullfile ioctl /dev/tty 0x5422file execute /usr/sbin/ntpd exec.realpath=/usr/sbin/ntpd exec.argv[0]=/usr/sbin/ntpdfile read /usr/lib64/gcc/x86_64-pc-linux-gnu/6.3.0/libgcc_s.so.1network unix dgram send /dev/logfile mkdir /run/openrc/daemons/ntpd/ 0755file create /run/openrc/daemons/ntpd/001 0666file read/write/unlink /run/openrc/daemons/ntpd/001file execute /lib64/rc/bin/eend exec.realpath=/lib64/rc/bin/eend exec.argv[0]=eendfile execute /lib64/rc/bin/service_set_value exec.realpath=/lib64/rc/bin/service_set_value exec.argv[0]=service_set_valuefile read /etc/servicesfile read /etc/host.conffile read /etc/resolv.conffile read /etc/hostsfile create /run/ntpd.pid 0666file read/write/unlink /run/ntpd.pidfile mkdir /run/openrc/options/ntpd/ 0755file read /etc/ntp.conffile create /run/openrc/options/ntpd/command 0666file read/write/unlink /run/openrc/options/ntpd/commandfile ioctl socket:[family=1:type=2:protocol=0] 0x8933file create /run/openrc/options/ntpd/pidfile 0666file read/write/unlink /run/openrc/options/ntpd/pidfilefile symlink /run/openrc/started/ntpd symlink.target=/etc/init.d/ntpdfile unlink /run/openrc/starting/ntpdfile symlink /run/openrc/stopping/ntpd symlink.target=/etc/init.d/ntpdfile unlink /run/openrc/started/ntpdfile execute /lib64/rc/bin/service_get_value exec.realpath=/lib64/rc/bin/service_get_value exec.argv[0]=service_get_valuefile unlink /run/openrc/stopping/ntpdfile rmdir /run/openrc/options/ntpd/file rmdir /run/openrc/daemons/ntpd/network inet dgram bind/send @ALLIPV6 123network inet dgram bind/send @ALLIPV4 123file ioctl socket:[family=2:type=2:protocol=17] 0x541Bfile read /etc/gai.confnetwork inet dgram send 127.0.0.1 53misc env *misc env \*file ioctl /dev/console 0x540Ffile ioctl /dev/console 0x5413file mkdir /sys/fs/cgroup/openrc/ntpd/ 0755file read/write /dev/consolefile read /etc/terminfo/l/linuxI need to remove all the profiles with use_profile 0 and use_group 0 using a bash script or any kind of script I can run on a linux system. I've toyed around with awk,grep, and sed but I haven't made any progress.I need to turn the above in to the below. Any tips, advice on what tools to use, or flat out showing me how would be much appreciated.<kernel> /usr/sbin/ntpdateuse_profile 3use_group 0misc env LS_COLORSmisc env LANGmisc env DISPLAYmisc env LC_CTYPEmisc env TERMmisc env XAUTHORITYmisc env PATHmisc env COLORTERMmisc env MAILmisc env LOGNAMEmisc env USERmisc env USERNAMEmisc env HOMEmisc env SHELLmisc env SUDO_COMMANDmisc env SUDO_USERmisc env SUDO_UIDmisc env SUDO_GIDnetwork unix dgram send /dev/logfile read /etc/nsswitch.conffile read /etc/servicesfile read /etc/host.conffile read /etc/resolv.conffile read /etc/hostsnetwork inet dgram send 127.0.0.1 53file ioctl socket:[family=2:type=2:protocol=17] 0x541Bfile read /etc/gai.confnetwork inet dgram bind/send :: 123network inet dgram bind/send 0.0.0.0 123<kernel> /etc/init.d/ntpduse_profile 3use_group 0misc env LS_COLORSmisc env LANGmisc env DISPLAYmisc env LC_CTYPEmisc env TERMmisc env XAUTHORITYmisc env PATHmisc env COLORTERMmisc env MAILmisc env LOGNAMEmisc env USERmisc env USERNAMEmisc env HOMEmisc env SHELLmisc env SUDO_COMMANDmisc env SUDO_USERmisc env SUDO_UIDmisc env SUDO_GIDfile read /sbin/openrc-runfile read /etc/rc.conffile read proc:/cmdlinefile read /etc/profile.envfile read proc:/cpuinfofile read proc:/1/environfile read /run/openrc/softlevelfile create /run/openrc/exclusive/ntpd 0664file write/unlink /run/openrc/exclusive/ntpdfile symlink /run/openrc/starting/ntpd symlink.target=/etc/init.d/ntpdfile read /run/openrc/depconfigfile read /run/openrc/deptreefile execute /lib64/rc/sh/openrc-run.sh exec.realpath=/lib64/rc/sh/openrc-run.sh exec.argv[0]=/lib64/rc/sh/openrc-run.shmisc env CONFIG_PROTECTmisc env CONFIG_PROTECT_MASKmisc env GCC_SPECSmisc env GSETTINGS_BACKENDmisc env INFOPATHmisc env LESSmisc env LESSOPENmisc env MANPAGERmisc env MANPATHmisc env OPENGL_PROFILEmisc env QT_GRAPHICSSYSTEMmisc env ROOTPATHmisc env VBOX_APP_HOMEmisc env XDG_CONFIG_DIRSmisc env XDG_DATA_DIRSmisc env RC_VERSIONmisc env RC_LIBEXECDIRmisc env RC_SVCDIRmisc env RC_TMPDIRmisc env RC_BOOTLEVELmisc env RC_RUNLEVELmisc env RC_DEFAULTLEVELmisc env RC_UNAMEmisc env EINFO_LOGmisc env RC_SVCNAMEmisc env RC_OPENRC_PIDmisc env RC_RUNSCRIPT_PIDmisc env RC_CMDfile read /bin/bashfile read/write /dev/ttyfile read /usr/lib64/locale/locale-archivefile read /etc/nsswitch.conffile read /etc/passwdfile ioctl devpts:/3 0x540Ffile read /lib64/rc/sh/openrc-run.shfile read /lib64/rc/sh/functions.shfile execute /lib64/rc/bin/eval_ecolors exec.realpath=/lib64/rc/bin/eval_ecolors exec.argv[0]=eval_ecolorsmisc env PWDmisc env SHLVLmisc env _file read /usr/share/terminfo/r/rxvt-unicode-256colorfile ioctl devpts:/3 0x5413file read /lib64/rc/sh/rc-functions.shfile read /lib64/rc/sh/rc-cgroup.shfile read /etc/conf.d/ntpdfile read /lib64/rc/sh/runit.shfile read /lib64/rc/sh/s6.shfile read /lib64/rc/sh/start-stop-daemon.shfile read /lib64/rc/sh/supervise-daemon.shfile write/truncate /sys/fs/cgroup/cpu/tasksfile write/truncate /sys/fs/cgroup/cpuacct/tasksfile write/truncate /sys/fs/cgroup/cpuset/tasksfile write/truncate /sys/fs/cgroup/freezer/tasksfile write/truncate /sys/fs/cgroup/memory/tasksfile write/truncate /sys/fs/cgroup/openrc/tasksfile execute /bin/mkdir exec.realpath=/bin/mkdir exec.argv[0]=mkdirmisc env RC_SERVICEmisc env SVCNAMEfile mkdir /sys/fs/cgroup/openrc/ntpd/ 0700file write/truncate /sys/fs/cgroup/openrc/ntpd/tasksfile read /etc/init.d/ntpdfile execute /lib64/rc/bin/ebegin exec.realpath=/lib64/rc/bin/ebegin exec.argv[0]=ebeginfile execute /sbin/start-stop-daemon exec.realpath=/sbin/start-stop-daemon exec.argv[0]=start-stop-daemonfile read/write /dev/nullfile ioctl /dev/tty 0x5422file execute /usr/sbin/ntpd exec.realpath=/usr/sbin/ntpd exec.argv[0]=/usr/sbin/ntpdfile read /usr/lib64/gcc/x86_64-pc-linux-gnu/6.3.0/libgcc_s.so.1network unix dgram send /dev/logfile mkdir /run/openrc/daemons/ntpd/ 0755file create /run/openrc/daemons/ntpd/001 0666file read/write/unlink /run/openrc/daemons/ntpd/001file execute /lib64/rc/bin/eend exec.realpath=/lib64/rc/bin/eend exec.argv[0]=eendfile execute /lib64/rc/bin/service_set_value exec.realpath=/lib64/rc/bin/service_set_value exec.argv[0]=service_set_valuefile read /etc/servicesfile read /etc/host.conffile read /etc/resolv.conffile read /etc/hostsfile create /run/ntpd.pid 0666file read/write/unlink /run/ntpd.pidfile mkdir /run/openrc/options/ntpd/ 0755file read /etc/ntp.conffile create /run/openrc/options/ntpd/command 0666file read/write/unlink /run/openrc/options/ntpd/commandfile ioctl socket:[family=1:type=2:protocol=0] 0x8933file create /run/openrc/options/ntpd/pidfile 0666file read/write/unlink /run/openrc/options/ntpd/pidfilefile symlink /run/openrc/started/ntpd symlink.target=/etc/init.d/ntpdfile unlink /run/openrc/starting/ntpdfile symlink /run/openrc/stopping/ntpd symlink.target=/etc/init.d/ntpdfile unlink /run/openrc/started/ntpdfile execute /lib64/rc/bin/service_get_value exec.realpath=/lib64/rc/bin/service_get_value exec.argv[0]=service_get_valuefile unlink /run/openrc/stopping/ntpdfile rmdir /run/openrc/options/ntpd/file rmdir /run/openrc/daemons/ntpd/network inet dgram bind/send @ALLIPV6 123network inet dgram bind/send @ALLIPV4 123file ioctl socket:[family=2:type=2:protocol=17] 0x541Bfile read /etc/gai.confnetwork inet dgram send 127.0.0.1 53misc env *misc env \*file ioctl /dev/console 0x540Ffile ioctl /dev/console 0x5413file mkdir /sys/fs/cgroup/openrc/ntpd/ 0755file read/write /dev/consolefile read /etc/terminfo/l/linux
How to remove multiple strings from a file using the shell
text processing;awk;sed;grep;regular expression
Your question is very similar to Print entire paragraph in a file on pattern match only that in your case it's sections of text delimited by <kernel>... and you want the opposite (i.e. delete the section that matches)  . You could adapt any of the solutions there to your needs, e.g. with sed:sed '/<kernel>/!{H;$!d;};x;/\nuse_profile 0\nuse_group 0\n/d' infileor, if your sed doesn't like that syntax:sed -e '/<kernel>/!{H;$!d' -e '}' -e 'x;/\nuse_profile 0\nuse_group 0\n/d' infile