#!/bin/bashread -p "请输入要查询的PID:" pidecho "--------------------------------"echo "进程PID:$pid"p_arr=("进程命令 11" "进程所属用户 1" "CPU占用率 2" "CPU内存占用率 4" "进程开始运行的时刻 9" "进程运行的时间 10" "进程状态 8" "进程虚拟内存 5" "进程共享内存 6")for item in "${p_arr[@]}"; doname=$(echo "$item" | awk '{ print $1}')index=$(echo "$item" | awk '{ print $2}')info=$(ps -aux | awk ' $2 ~ /^'$pid'/ { print $'$index' }')echo "${name}: ${info}"
doneecho "--------------------------------"