1.shell脚本查询指定进程并杀死
#!/bin/bash
pids=$(ps -ef | grep "${name}" | grep -v "$0" | grep -v grep | awk '{print $2}') # name是进程名称
for pid in ${pids}
do
kill -9 ${pid}
done
2.gcc编译代码
#!/bin/bash
#set -x
_file=$1
_bin=${_file%.*}
_suffix=${_file#*.}
echo "file:${_bin} suffix:${_suffix}"
if [[ -x ${_file} ]]; then
if [[ -e ${_file}.c ]]; then
gcc -g ${_file}.c -o ${_bin}
elif [[ -e ${_file}.cpp ]]; then
g++ -g -std=c++11 ${_file}.cpp -o ${_bin}
fi
elif [[ -e ${_file} ]]; then
if [[ ${_suffix} == "c" ]]; then
gcc -g ${_file} -o ${_bin}
else
g++ -g -std=c++11 ${_file} -o ${_bin}
fi
fi