linux编程

2014/12/30 13:12:26翻牌: 3735临幸: 1
    初学linux的socket编程,写几个简单的小实例。程序在http://download.csdn.net/download/longmenwaideyu/8112301 和 https://github.com/longmenwaideyu/linuxUDPChatroom都可以下载chatServer.c#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <netdb.h> #include <sys/soc...
2015/4/18 16:15:38翻牌: 6294临幸: 0
一、预备知识1. 文件描述符File Descriptor    Linux shell中的File Descriptor可以理解为一个指向文件的指针。默认有三个FD:0,1,2。分别指向的是:Keyboard设备文件,Moniter设备文件,和Moniter设备文件。Shell中还允许有3..9的FD,默认都没有打开,可以认为指向的为null。可以通过一下命令查看得开的FD:ls /proc/self/fd返回的数字代表FD的值。利用重定向可以为一个FD赋值,使其指向一个非null的文件,其实就是打开一个FD。6>&1可以理解为将FD6指针指向FD1指针指向的文件,既Moniter。这样,...
2015/5/26 8:43:25翻牌: 4993临幸: 1
官方教程地址http://stedolan.github.io/jq/tutorial/1、获取JSON数据我们以github上jq项目最新5条评论的JSON数据为例。获取数据如下:curl "https://api.github.com/repos/stedolan/jq/commits?per_page=5"2、高亮并按属性排序显示用 jq "."即可:curl "https://api.github.com/repos/stedolan/jq/commits?per_page=5" | jq "."结果:这里的评论内容比较多,我们现在想拿第一个评论。3、获取数组某一项curl "http...