Shell 编程-学习笔记

来源:互联网 发布:windows处于通知模式 编辑:程序博客网 时间:2024/04/29 12:11

1. 批量kill某个进程

#!/bin/bash

pid = $(ps -ef|grep lotus | awk '{print $2}')  #  ps(process status)结果的第二个参数为进程ID号

for x in $pid

do

    kill -9 $pid

done

 

2. shell 函数的编写

 

function AddPerm(){

chmod u+x $*

}

 

可以将函数写在 ~/.bash_profile 里面, 要想函数在当前的bash 窗口生效的话,可以执行 source ~/.bash_profile

此时你要想修改多个文件的执行权限的话,就可以直接输入: AddPerm file1 file2 filen

原创粉丝点击