【转】linux if 判断】的更多相关文章

Title:Linux C判断字符串是否为数字  --2013-10-14 15:54 #include <ctype.h> #include <string.h> int IsInt(char* str) { int len; len = strlen(str); int i=0; for(i;i<len;i++) { if(!(isdigit(str[i]))) return 0; } return 1; }…
Title:Linux C判断日期格式是否合法 --2013-10-11 11:54 #include <string.h> // strlen() , strncpy() #include <ctype.h> // isdigit() #include <stdlib.h> // atoi() #include <stdio.h> /*有效格式 2013-01-01 01:01:01 2013/11/11 11:11:11 */ int main() {…
/************************************************************************* * Linux Shell 判断块设备节点是否存在 * 说明: * 能牌问shell脚本-f不能判断mmc设备节点的问题,查了一下资料,发现不能 * 使用-f来判断,要使用-e或者-b来判断才行. * * 2017-1-17 深圳 南山平山村 曾剑锋 *************************************************…
在linux中判断文件,目录是否存在或则具有的权限,根据最近的学习以及网上的资料,进行了以下的总结: #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x "$myPath"]; then mkdir "$myPath" fi #这里的-d 参数判断$m…
每一条基本命令执行后都有一个返回码,该返回码是用$?表示,执行成功的返回码是0,例如:if [ $? -ne 0 ];then 上一命令执行失败时的操作else 上一命令执行成功时的操作fi例如linux中启动JBoss判断是否启动成功service IMX_JBossAS startif [$? -ne 0 ];then echo "失败"else echo "成功"fi…
自己服务器的输出 1. 查看物理CPU的个数   #cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l    1 2. 查看逻辑CPU的个数 #cat /proc/cpuinfo |grep "processor"|wc -l  8 3. 查看CPU是几核 #cat /proc/cpuinfo |grep "cores"|uniq  cpu cores : 4 4. 查看CPU的主频 #c…
大小端的定义无需赘言,常用的方法有使用联合体和指针法,如: int checkCPU() { union w { int a; char b; }c; c.a = 1; return (c.b == 1); // 小端返回TRUE,大端返回FALSE } 实际上Linux操作系统的源码中,其判断更为简洁: static union { char c[4]; unsigned long mylong; } endian_test = {{ 'l', '?', '?', 'b' } }; #defi…
UNIX Shell 里面比较字符写法: -eq   等于-ne    不等于-gt    大于-lt    小于-le    小于等于-ge   大于等于-z 空串=    两个字符相等!=    两个字符不等-n    非空串 无论什么编程语言都离不开条件判断.SHELL也不例外. 大体的格式如下:if list thendo something hereelif list thendo another thing hereelsedo something else herefi 一个例子:…
如何判断自己的服务器是否被入侵了呢?仅仅靠两只手是不够的,但两只手也能起到一些作用,我们先来看看UNIX系统上一些入侵检测方法,以LINUX和solaris为例. 1.检查系统密码文件 首先从明显的入手,查看一下passwd文件,ls –l /etc/passwd查看文件修改的日期. 检查一下passwd文件中有哪些特权用户,系统中uid为0的用户都会被显示出来. awk –F:’$3==0 {print $1}’ /etc/passwd 顺便再检查一下系统里有没有空口令帐户: awk –F:…
1.利用if ...then if [ 判断条件 ];then 指令 fi 实例一 Y/N: #!/bin/bash #Program: # This program shows "Hello World!" in your screen. #History: # // lzyer First release read -p "Please input (Y/N)? " yn if [ "${yn}" == "Y" ] ||…