ls /proc/
1 10984 11246 131 144 167 2099 31788 4805 5375 6762 7594 8111 8722 consoles
10 10993 11247 1314 14400 168 21 32 4807 5379 6771 76 8112 8738 cpuinfo
100 10998 11248 13163 14403 169 210 32408 4818 5386 6788 7601 8113 8752 crypto
101 11 11249 132 14404 17 211 33 4831 5388 68 7619 8114 8768 devices
102 110 11251 133 14405 170 2111 34 4833 54 6808 7625 8115 8789 diskstats
10202 11012 11252 134 14406 1726 2115 3489 4846 5417 6827 7626 8116 88 dma
cat /proc/10993/root/run_command
/usr/sbin/libvirtd --listen(nova-libvirt)
모든 PID run_command를 얻고 싶습니다.
cd /proc
cat */root/run_command
/etc/barbican/vassals --logto /var/log/kolla/barbican/barbican-api.loguwsgi --master --emperor /etc/barbican/vassals --logto /var/log/kolla/barbican/barbican-api.loguwsgi --master --emperor /etc/barbican/vassals --logto /var/log/kolla/barbican/barbican-api.log/opt/kibana/bin/kibanabarbican-keystone-listenerbarbican-keystone-listenerheat-api-cfnheat-api-cfnneutron-dhcp-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/dhcp_agent.inimistral-server --server executor --config-file /etc/mistral/mistral.confneutron-dhcp-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/dhcp_agent.inimistral-server --server executor --config-file /etc/mistral/mistral.conf/usr/sbin/sshd -Dtacker-server --config-file /etc/tacker/tacker.conf/usr/sbin/sshd -Dtacker-server --config-file /etc/tacker/tacker.conf/usr/sbin/apache2/usr/sbin/td-agent/usr/bin/mysqld_safeglance-registry/usr/sbin/apache2start-ovsdb-server 127.0.0.1/usr/bin/mysqld_safeglance-registrynova-apistart-ovsdb-server 127.0.0.1nova-consoleauthnova-api/usr/sbin/libvirtd --listennova-consoleauth/usr/bin/memcached -v -l 10.60.6.174 -p 11211 -c 5000 -U 0/usr/bin/memcached -v -l 10.60.6.174 -p 11211 -c 5000 -U 0/usr/sbin/libvirtd --listenneutron-metadata-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/metadata_agent.ini/usr/sbin/libvirtd --listenmistral-server --server engine --config-file /etc/mistral/mistral.confneutron-metadata-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/metadata_agent.inimistral-server --server engine --config-file /etc/mistral/mistral.confstart-ovsdb-server 127.0.0.1/usr/share/elasticsearch/bin/elasticsearchsleep infinity/usr/share/elasticsearch/bin/elasticsearchbarbican-workersleep infinitynova-conductorbarbican-worker/opt/kafka/bin/kafka-server-start.sh /etc/kafka/kafka.server.propertiesnova-compute/usr/sbin/libvirtd --listen/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2/usr/sbin/apache2no ...
하지만 읽기에는 너무 혼란스럽습니다. 각 기록(각 파일의 내용)을 어떻게 별도의 줄에 넣을 수 있나요?
run_comand_content1
run_comand_content2
run_comand_content3
또는
run_comand_content1
run_comand_content2
run_comand_content3
답변1
루프에 넣을 수 있습니다.
/proc/[0-9]*의 경우 하다 printf "${i}\t" cat${i}/root/run_command "\n" 인쇄 완벽한
답변2
당신은 그것을 사용할 수 있습니다 awk
:
awk 'FNR==1{printf ""}1' */root/run_command
또는 ---
줄바꿈으로 구분합니다.
awk 'FNR==1{print "---"}1' */root/run_command
awk 'FNR==1{printf "\n"}1' */root/run_command
여기를 보아라다음을 사용하는 것과 같은 추가 답변 sed
:
sed -e '$s/$/\n/' -s */root/run_command