method One:
Locate_library () {[!] "$1*" = "' echo $1* '"]; }
Usage:
# Look for PAM (do weirdly due to distribution bugs (e.g. Debian) or the
# Crypt library.
If Find_func Pam_start SYSDEPUTIL.O; Then
locate_library/lib/libpam.so.0 && echo "/lib/libpam.so.0";
Locate_library/usr/lib/libpam.so && echo "-lpam";
Locate_library/usr/lib64/libpam.so && echo "-lpam";
# HP-UX ends shared libraries with. SL
locate_library/usr/lib/libpam.sl && echo "-lpam";
# AIX ends shared libraries with. A
locate_library/usr/lib/libpam.a && echo "-lpam";
else
locate_library/lib/libcrypt.so && echo "-lcrypt";
Locate_library/usr/lib/libcrypt.so && echo "-lcrypt";
Locate_library/usr/lib64/libcrypt.so && echo "-lcrypt";
Fi
Method Two:
#!/bin/sh
mypath= "/var/log/httpd/"
myfile= "/var/log/httpd/access.log"
#这里的-x parameter judgment $ MyPath exists and has executable permissions if
[!-x $myPath]; then
mkdir "$myPath"
fi
#这里的-D parameters to determine if $mypath exists if
[!-D "$myPath"]; Then
mkdir "$myPath"
fi
#这里的-F parameter to determine if there is an
if [!-F "$myFile"]; then touch
"$myFile"
Fi
#其他参数还有-n,-n is to determine whether a variable has a value of if
[!-n "$myVar"]; then
echo "$myVar is empty"
exit 0
fi
#两个变量判断是否相等
if ["$var 1" = "$var 2"]; then
echo ' $var 1 eq $var 2 '
else
Echo ' $var 1 don't eq $var 2 '
fi
The identification and meaning of various judgments are as follows:
-A file exists.
-B file exists and is a block special file.
-c file exists and is a character special file.
-D file exists and is a directory.
-e file exists (just the same as-a).
-F file exists and is a regular file.
-G file exists and has its setgid (2) bit set.
-G file exists and has the same group ID as this process.
-K file exists and has its sticky bit set.
-l file exists and is a symbolic link.
-N string length is not zero.
-o Named option is set on.
-O file exists and is owned by the user ID of this process.
-P file exists and is a-a-a-in-a-a-i-Special file or
Named pipe.
-R file exists and is readable by the current process.
-S file exists and has a size greater than zero.
-s file exists and is a socket.
-T file descriptor number Fildes is open and associated with a
Terminal device.
-U file exists and has its setuid (2) bit set.
-W file exists and is writable by the current process.
-X file exists and is executable by the current process.
-Z string length is zero.