Weather : cloudy to suny
一、需求:
把當前用戶下全部進程名字中含有「gecz」的進程關閉。bash
[root@Dasoncheng sbin]# cat c.sh #!/bin/bash ps -u $USER |awk '$NF ~ /gecz/ {print $1}' |xargs kill &>/dev/null if [ $? -eq 0 ]; then echo "it is ok" else echo "error" fi
answer referred:code
#!/bin/bash ps -u $USER |awk '$NF ~ /gecz/ {print $1}' |xargs kill