1.Linux的查找命令,在文件夹中查找特定字符串
查找目录下的所有文件中是否含有某个字符串
find .|xargs grep -ri "IBM"查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名
find .|xargs grep -ri "IBM" -l
2.判断某一个进程是否存在
pgrep process_name
if [ $? -eq 1 ] ; then
echo "############# process don't exist ##############"
else
echo "############# process exist ##############"
fi
3.判断当前使用的Linux主机系统类型ubuntu?fedora?
OS_VERSION=`cat /proc/version`
if echo $OS_VERSION | grep -qi "Ubuntu"
then
OS_NAME="Ubuntu"
echo "Running on OS "$OS_NAME
elif echo $OS_VERSION | grep -qi "Fedora"
then
OS_NAME="Fedora"
echo "Running on OS "$OS_NAME
else
echo "Warning:unknown OS Name."
fi
if [ "$OS_NAME" = "Ubuntu" ];then
echo "Hello Ubuntu"
elif [ "$OS_NAME" = "Fedora" ];then
echo "Hello Fedroa"
else
echo "Warning:unknown OS."
fi