我正在尝试通过以下命令在Linux系统中运行tomcat服务
chkconfig --list | grep -i在| sed -n'/ tomcat / p'| awk'{print $ 1}'
我得到的输出是
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
tomcat9
我只想获取服务名称“ tomcat9”。我需要在命令中进行哪些更改?
答案 0 :(得分:1)
添加此awk
过滤器:
|awk -v skip=-1 '/^Note:/{skip=7} skip-- >= 0{next} 1'
如果第一行中的第一个单词为“注:”,则跳过七行。