posted @ 2011-09-27 16:23 xsong 閱讀(1310) | 評(píng)論 (0) | 編輯 收藏
[ -a FILE ] 如果 FILE 存在則為真。
[ -b FILE ] 如果 FILE 存在且是一個(gè)塊特殊文件則為真。
[ -c FILE ] 如果 FILE 存在且是一個(gè)字特殊文件則為真。
[ -d FILE ] 如果 FILE 存在且是一個(gè)目錄則為真。
[ -e FILE ] 如果 FILE 存在則為真。
[ -f FILE ] 如果 FILE 存在且是一個(gè)普通文件則為真。
[ -g FILE ] 如果 FILE 存在且已經(jīng)設(shè)置了SGID則為真。
[ -h FILE ] 如果 FILE 存在且是一個(gè)符號(hào)連接則為真。
[ -k FILE ] 如果 FILE 存在且已經(jīng)設(shè)置了粘制位則為真。
[ -p FILE ] 如果 FILE 存在且是一個(gè)名字管道(F如果O)則為真。
[ -r FILE ] 如果 FILE 存在且是可讀的則為真。
[ -s FILE ] 如果 FILE 存在且大小不為0則為真。
[ -t FD ] 如果文件描述符 FD 打開且指向一個(gè)終端則為真。
[ -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 存在且是一個(gè)符號(hào)連接則為真。
[ -N FILE ] 如果 FILE 存在 and has been mod如果ied since it was last read則為真。
[ -S FILE ] 如果 FILE 存在且是一個(gè)套接字則為真。
[ 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é)點(diǎn)號(hào)則為真。
[ -o OPTIONNAME ] 如果 shell選項(xiàng) “OPTIONNAME” 開啟則為真。
[ -z STRING ] “STRING” 的長(zhǎng)度為零則為真。
[ -n STRING ] or [ STRING ] “STRING” 的長(zhǎng)度為非零 non-zero則為真。
[ STRING1 == STRING2 ] 如果2個(gè)字符串相同。 “=” 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.
摘要: 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) | 評(píng)論 (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;
}
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) | 評(píng)論 (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;
}
#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) | 評(píng)論 (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"
// 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) | 評(píng)論 (0) | 編輯 收藏