2014年2月25日

Linux shell ${}简单用法

摘要: [转]http://linux.chinaunix.net/techdoc/develop/2007/05/05/956956.shtml为了完整起见,我这里再用一些例子加以说明 ${ } 的一些特异功能:假设我们定义了一个变量为:file=/dir1/dir2/dir3/my.file.txt我们可以用 ${ } 分别替换获得不同的值:${file#*/}:拿掉第一条 / 及其左边的字符串:dir1/dir2/dir3/my.file.txt${file##*/}:拿掉最后一条 / 及其左边的字符串:my.file.txt${file#*.}:拿掉第一个 . 及其左边的字符串:file.tx 阅读全文

posted @ 2014-02-25 20:56 旭东的博客 阅读(39041) 评论(0) 推荐(1)

C/C++ 获取目录下的文件列表信息

摘要: 在C/C++编程时,需要获取目录下面的文件列表信息。1.数据结构struct dirent{ long d_ino; /* inode number 索引节点号 */ off_t d_off; /* offset to this dirent 在目录文件中的偏移 */ unsigned short d_reclen; /* length of this d_name 文件名长 */ unsigned char d_type; /* the type of d_name 文件类型 */ char d_name [NAME_MAX+1]; /* file... 阅读全文

posted @ 2014-02-25 13:56 旭东的博客 阅读(20898) 评论(0) 推荐(0)

导航