2011年5月30日

          [ -a FILE ] 如果 FILE 存在則為真。
          [ -b FILE ] 如果 FILE 存在且是一個塊特殊文件則為真。
          [ -c FILE ] 如果 FILE 存在且是一個字特殊文件則為真。
          [ -d FILE ] 如果 FILE 存在且是一個目錄則為真。
          [ -e FILE ] 如果 FILE 存在則為真。
          [ -f FILE ] 如果 FILE 存在且是一個普通文件則為真。
          [ -g FILE ] 如果 FILE 存在且已經(jīng)設(shè)置了SGID則為真。
          [ -h FILE ] 如果 FILE 存在且是一個符號連接則為真。
          [ -k FILE ] 如果 FILE 存在且已經(jīng)設(shè)置了粘制位則為真。
          [ -p FILE ] 如果 FILE 存在且是一個名字管道(F如果O)則為真。
          [ -r FILE ] 如果 FILE 存在且是可讀的則為真。
          [ -s FILE ] 如果 FILE 存在且大小不為0則為真。
          [ -t FD ] 如果文件描述符 FD 打開且指向一個終端則為真。
          [ -u FILE ] 如果 FILE 存在且設(shè)置了SUID (set user ID)則為真。
          [ -w FILE ] 如果 FILE 如果 FILE 存在且是可寫的則為真。
          [ -x FILE ] 如果 FILE 存在且是可執(zhí)行的則為真。
          [ -O FILE ] 如果 FILE 存在且屬有效用戶ID則為真。
          [ -G FILE ] 如果 FILE 存在且屬有效用戶組則為真。
          [ -L FILE ] 如果 FILE 存在且是一個符號連接則為真。
          [ -N FILE ] 如果 FILE 存在 and has been mod如果ied since it was last read則為真。
          [ -S FILE ] 如果 FILE 存在且是一個套接字則為真。
          [ FILE1 -nt FILE2 ] 如果 FILE1 has been changed more recently than FILE2, or 如果 FILE1FILE2 does not則為真。 exists and
          [ FILE1 -ot FILE2 ] 如果 FILE1 比 FILE2 要老, 或者 FILE2 存在且 FILE1 不存在則為真。
          [ FILE1 -ef FILE2 ] 如果 FILE1 和 FILE2 指向相同的設(shè)備和節(jié)點號則為真。
          [ -o OPTIONNAME ] 如果 shell選項 “OPTIONNAME” 開啟則為真。
          [ -z STRING ] “STRING” 的長度為零則為真。
          [ -n STRING ] or [ STRING ] “STRING” 的長度為非零 non-zero則為真。
          [ STRING1 == STRING2 ] 如果2個字符串相同。 “=” may be used instead of “==” for strict POSIX compliance則為真。
          [ STRING1 != STRING2 ] 如果字符串不相等則為真。
          [ STRING1 < STRING2 ] 如果 “STRING1” sorts before “STRING2” lexicographically in the current locale則為真。
          [ STRING1 > STRING2 ] 如果 “STRING1” sorts after “STRING2” lexicographically in the current locale則為真。
          [ ARG1 OP ARG2 ] “OP” is one of -eq, -ne, -lt, -le, -gt or -ge. These arithmetic binary operators return true if “ARG1” is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to “ARG2”, respectively. “ARG1” and “ARG2” are integers.

          posted @ 2011-09-27 16:23 xsong 閱讀(1310) | 評論 (0)編輯 收藏

               摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//源代碼class TT{       static int tt = 5;&nb...  閱讀全文

          posted @ 2011-09-23 13:55 xsong 閱讀(344) | 評論 (0)編輯 收藏

          #include <stdio.h>

          int main(int argc, char **argv) {

              
          /**
               * sizeof  關(guān)鍵字
               
          */
              
          int i=0;
              printf(
          "sizeof int %lu \n",sizeof(i)); // 4

              
          int *p=NULL;
              printf(
          "sizeof point %lu \n" ,sizeof(p) )    ; // 8
              printf("sizeof *p %lu \n",sizeof *p); // 4

              
          int a[100];
              printf(
          "sizeof array %lu \n"sizeof(a));// 100*4
              printf("sizeof a[100] %lu \n",sizeof(a[100])); // 4
              printf("sizeof &a %lu \n"sizeof(&a)); // 8  &a 是指針

              
          return 0;
          }

          posted @ 2011-09-16 15:04 xsong 閱讀(230) | 評論 (0)編輯 收藏

          #include <stdio.h>
          #include 
          <stdlib.h>
          #include 
          <event.h>
          #include 
          <evhttp.h>

          void generic_request_handler(struct evhttp_request *req, void *arg) {

              
          struct evbuffer *return_buffer=evbuffer_new();

              evbuffer_add_printf(return_buffer,
          "welcome");
              evhttp_send_reply(req,HTTP_OK,
          "Client",return_buffer    );
              evbuffer_free(return_buffer);
          }

          int main(int argc, char **argv) {
              
          short http_port =8082;
              
          char *http_addr="127.0.0.1";
              
          struct evhttp *http_serv=NULL;
              event_init();

              http_serv
          = evhttp_start(http_addr,http_port);
              evhttp_set_gencb(http_serv,generic_request_handler,NULL);
              event_dispatch();
              
          return 0;
          }

          posted @ 2011-08-05 14:51 xsong 閱讀(1355) | 評論 (0)編輯 收藏

          enum Action {Start, Stop, Rewind, Forward};

          // Special type of class 
          enum Status {
            Flunk(
          50), Pass(70), Excel(90);
            
          private final int value;
            Status(
          int value) { this.value = value; }
            
          public int value() { return value; } 
          };

          Action a 
          = Action.Stop;
          if (a != Action.Start)
            System.out.println(a);               
          // Prints "Stop"

          Status s 
          = Status.Pass;
          System.out.println(s.value());      
          // Prints "70"

          posted @ 2011-08-01 16:20 xsong 閱讀(220) | 評論 (0)編輯 收藏

          posted @ 2011-07-04 15:44 xsong 閱讀(299) | 評論 (0)編輯 收藏

          安裝  編輯 ~/.vimrc

          syntax on
          set tabstop=4
          set softtabstop=4
          set shiftwidth=4
          set autoindent
          set cindent
          set nu

          if &term=="xterm"
            set t_Co=8
            set t_Sb=^[[4%dm
            set t_Sf=^[[3%dm
          endif

          let g:neocomplcache_enable_at_startup = 1 


          "括號補全功能,

          :inoremap ( ()<ESC>i
                  :inoremap ) <c-r>=ClosePair(')')<CR>
          :inoremap { {}<ESC>i
              :inoremap } <c-r>=ClosePair('}')<CR>
              :inoremap [ []<ESC>i
              :inoremap ] <c-r>=ClosePair(']')<CR>
              :inoremap < <><ESC>i
              :inoremap > <c-r>=ClosePair('>')<CR>

              function ClosePair(char)
              if getline('.')[col('.') - 1] == a:char
              return "\<Right>"
              else
              return a:char
              endif
              endf

          posted @ 2011-06-11 12:58 xsong 閱讀(741) | 評論 (0)編輯 收藏

              c 提供了 atoi atof 等函數(shù)實現(xiàn)了字符串轉(zhuǎn)化數(shù)值的函數(shù)。使用方法簡單。
          但是如果轉(zhuǎn)化 "123ss"等字符串里包含非數(shù)值的字符串時,則會自動轉(zhuǎn)化為 123,不會拋出異常。
          想要驗證 字符串是否是數(shù)值格式  可使用
          strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base)
           nptr指向的字符串, 
          strtol()函數(shù)檢測到第一個非法字符時,立即停止檢測,其后的所有字符都會被當作非法字符處理。合法字符串會被轉(zhuǎn)換為long int, 作為函數(shù)的返回值。非法字符串,即從第一個非法字符的地址,被賦給*endptr。**endptr是個雙重指針,即指針的指針。strtol()函數(shù)就是通過它改變*endptr的值,即把第一個非法字符的地址傳給endptr。

              char *str1="1231",*endptr1;
              
          char *str2="123sss",*endptr2;

              printf(
          "atoi str2 is %i\n",atoi(str1));
              
          int i,j;//atoi(str);
              i=strtol(str1,&endptr1,10);
              
          if(*endptr1!=NULL){
                  printf(
          "endptr1 is %s\n",endptr1);
              }
              printf(
          "str1 auto int %i\n",i);
              j
          =strtol(str2,&endptr2,10);
              
          if(*endptr2!=NULL){
                  printf(
          "endptr2 is %s\n",endptr2);
              }
              printf(
          "str2 auto long int %i\n",j);

          posted @ 2011-05-30 15:13 xsong 閱讀(596) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 达尔| 宣恩县| 洪雅县| 高安市| 江西省| 临潭县| 永川市| 巨野县| 萨嘎县| 化隆| 静安区| 诸暨市| 襄樊市| 蒙山县| 宜阳县| 保康县| 新余市| 莒南县| 沾化县| 瑞金市| 娄烦县| 珲春市| 金溪县| 玉环县| 肃北| 驻马店市| 湖州市| 师宗县| 兴国县| 称多县| 鄂尔多斯市| 陆川县| 东乌珠穆沁旗| 高陵县| 遵义县| 安庆市| 察雅县| 紫云| 务川| 吴桥县| 扬中市|