coanor

时间总在流逝,思绪过处,留下只言片语。

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年9月25日

摘要: 这两天想用一下gprof。拿出几天前写的插入排序代码,排序所有的英文单词。这所有的单词加起来有216,555个之多,作为测试数据足以。将单词拷贝下来,用Vim切割一番,基本也就单行一个单词了,这样便于直接调用I/O接口读取,比如fgets。很久没有写文件I/O方面的代码,这个函数的细节居然给忘记了,翻开APUE,将Standard I/O Library一章扫了一遍,算是复习了一遍。其实man一下fgets也可以找到相关的信息。然后下面是读文件的代码:#include <stdio.h>#define MAX_WORD_LEN 16int read_string_data(char 阅读全文
posted @ 2012-09-25 02:39 coanor 阅读(453) 评论(0) 推荐(0) 编辑

2012年9月20日

摘要: #!/bin/bash: list all users.PASSWORD_FILE=/etc/passwdn=1for name in $(awk 'BEGIN{FS=":"}{print $1}' < "$PASSWORD_FILE" )do echo "USER #$n = $name" let "n+=1"doneexit $?#!/bin/bash# bin-grep.sh: locates matching strings in a binary file.E_BADARGS=65E 阅读全文
posted @ 2012-09-20 00:58 coanor 阅读(183) 评论(0) 推荐(0) 编辑

2012年9月19日

摘要: 1 #!/bin/bash 2 a=4 3 b=5 4 5 echo 6 if [ "$a" -ne "$b" ] 7 then 8 echo "$a is not equal to $b" 9 echo "(arithmetic comparison)"10 fi11 12 echo13 14 if [ "$a" != "$b" ]15 then16 echo "$a is not equal to $b"17 echo "(string co 阅读全文
posted @ 2012-09-19 00:24 coanor 阅读(121) 评论(0) 推荐(0) 编辑

2012年9月18日

摘要: # these shell code used to test file attributes# block devicedevice0="/dev/sda2"if [ -b "$device0" ]then echo "$device0 is a block device."fi# character devicedevice1="/dev/ttyS1" # PCMCIA modem cardif [ -c "$device1" ]then echo "$device is a ch 阅读全文
posted @ 2012-09-18 01:41 coanor 阅读(163) 评论(0) 推荐(0) 编辑