思路: ps -elf查看进程ppid根据ppid赛选pid进程#!/bin/bash#The script is used to print child processes.#Date 2021-01-16file=/tmp/pid.txt #定义文本路径while :doread -p "please input a pid: " pidif [ -z $pid ];then#判断是否为空        echo "The input can not be empty (input q or quit to exit)."        continueelif [ $pid == "q" ]||[ $pid == "quit" ];then#退出循环        echo "exit."        exitfips -elf| awk -v pid2=$pid '$5==pid2 {print $0}'>$file#筛选pidif ! grep -qw "$pid" $file;then#过滤pid        echo "The input pid does not exist (input q or quit to exit)."        continuefibreakdonechild_pid() {        ps -elf|awk -v pid_new=$1 '$5==pid_new {print $4}' >$1.txt                #将进程id写入文本        n=`wc -l $1.txt| awk '{print $1}'`        if [ $n -eq 0 ];then        echo "There are no subprocess under the pid $1"        elif [ $n -ne 0 ];then        echo "The pid $1 subprocess according to following:"                cat $1.txt        fi}#定义筛选函数child_pid $pidfor i in `cat $pid.txt`#for循环将每个子进程包含的子进程筛选出do        child_pid $idonefor i in `cat $pid.txt`#for循环遍历删除文本do        [ -f $i.txt ] && rm $i.txtdone[ -f $pid.txt ] && rm $pid.txt#删除文本

更多相关文章

  1. 使用后台进程和 Shutdown Hook 友好地关闭 Tomcat
  2. jQuery——将title属性用作悬停的文本,但只在同一父类中使用。
  3. 如何在java脚本中获取节点内部文本?
  4. jquery 监控文本框键盘事件(回车事件),附常用keycode值。
  5. 使用jQuery更新textarea值更改的文本
  6. 输入-文本对齐:用jQuery右填充输入
  7. 如何使用javascript/jquery获取文本框数组值
  8. 解析PHP的基本文本输出
  9. 在体html中搜索文本的最佳方法是什么?

随机推荐

  1. ListView设置分割线Divider样式
  2. android之多线程工作(一)AsyncTask .
  3. Android(cacerts.bks)添加根证书
  4. android 透明activity
  5. 使用Android Studio创建Android Wear项目
  6. TextView 中文字滚动的必要条件
  7. Android HTTP
  8. Java代码设置Android全屏
  9. Could not find SDK_Root\tools\adb.ex
  10. android上实现蓝牙透传时遇到点问题