Saturday, July 31, 2010
Wednesday, July 28, 2010
grep excludes files, directories
grep -Ir --exclude="*\.svn*" "pattern" *
note that the grep path is the full path, not just the file names!
grep regular exp.
Here, we outline the special characters for grep. Note that in egrep (which uses extended regular expressions), which actually are no more functional than standard regular expressions if you use GNU grep ) , the list of special characters increases ( | in grep is the same as \| egrep and vice versa, there are also other differences. Check the man page for details ) The following characters are considered special and need to be "escaped":
Note that a $ sign loses its meaning if characters follow it (I think) and the carat ^ loses its meaning if other characters precede it.? \ . [ ] ^ $
Square brackets behave a little differently. The rules for square brackets go as follows:
- A closing square bracket loses its special meaning if placed first in a list. for example
[]12]
matches ] , 1, or 2. - A dash - loses it's usual meaning inside lists if it is placed last.
- A carat ^ loses it's special meaning if it is not placed first
- Most special characters lose their meaning inside square brackets
- * if at the beginning of the regular exps, lose its meaning.
A regular expression may be followed by one of several repetition operators:
? The preceding item is optional and matched at most once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{n} The preceding item is matched exactly n times.
{n,} The preceding item is matched n or more times.
{n,m} The preceding item is matched at least n times, but not more than m times.
In basic regular expressions the metacharacters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions
\?, \+, \{, \|, \(, and \).
Monday, July 19, 2010
sed summary (cont)
\d = [[:digit:]], \D = [^[:digit:]].
\s = [[:whitespace:]], including space, tab .. ; \S = ?
\w = [[:alnum:]], including 0-9,a-z, A-Z; \W = ?
executing multiple commands with sed -e command
One method of combining multiple commands is to use a -e before each command:
sed -e 's/a/A/' -e 's/b/B/'
A "-e" isn't needed in the earlier examples because sed knows that there must always be one command. If you give sed one argument, it must be a command, and sed will edit the data read from standard input.
Reversing the restriction with !
Sometimes you need to perform an action on every line except those that match a regular expression, or those outside of a range of addresses. The "!" character, which often means not in Unix utilities, inverts the address restriction. You remember that
sed -n '/match/ p'acts like the grep command. The "-v" option to grep prints all lines that don't contain the pattern. Sed can do this with sed -n '/match/ !p'
Ranges by Line Number
You can specify a range on line numbers by inserting a comma between the numbers. To restrict a substitution to the first 100 lines, you can use:
- sed '1,100 s/A/a/'
If you know exactly how many lines are in a file, you can explicitly state that number to perform the substitution on the rest of the file. In this case, assume you used wc to find out there are 532 lines in the file:
- sed '101,532 s/A/a/'
An easier way is to use the special character "$," which means the last line in the file.
- sed '101,$ s/A/a/'
The "$" is one of those conventions that mean "last" in utilities like cat -e, vi, and ed. "cat -e" Line numbers are cumulative if several files are edited. That is,
- sed '200,300 s/A/a/' f1 f2 f3 >new
is the same as
cat f1 f2 f3 | sed '200,300 s/A/a/' >newTransform with Y
If you wanted to change a word from lower case to upper case, you could write 26 character substitutions, converting "a" to "A," etc. Sed has a command that operates like the tr program. It is called the "y" command. For instance, to change the letters "a" through "f" into their upper case form, use:
- sed 'y/abcdef/ABCDEF/' file
I could have used an example that converted all 26 letters into upper case, and while this column covers a broad range of topics, the "column" prefers a narrower format.
If you wanted to convert a line that contained a hexadecimal number (e.g. 0x1aff) to upper case (0x1AFF), you could use:
- sed '/0x[0-9a-zA-Z]*/ y/abcdef/ABCDEF' file
This works fine if there are only numbers in the file. If you wanted to change the second word in a line to upper case, you are out of luck - unless you use multi-line editing. (Hey - I think there is some sort of theme here!)
Thursday, July 15, 2010
Thursday, July 8, 2010
How to manage experimental data
We will follow these practices in the future.
We will use the excel or OpenOffice to store the data.
The format is:
In the first table, it is about the overall indexing of the tables needed in experiment.
Next, in each table, it will only store one closely related set of data. For example, when you measure the performance of an algorithm, you may want to measure the running time of the algorithm, also, you want to store the space efficiency of the algorithm. So, in the first page, it will be the name of the two tables and some brief intro to these tables. It is better off including the name of the datasets in the first page. In the second page, it is the time table, which could be the running time of the algorithm, and the running time of some other strawman algorithms. Also, it could include the preprocessing time of the algorithm...
Another question is how to manage the raw data. Raw data is the data that is not yet processed.
For each raw data table, we will need to record the original source of the data, the name of the data.
Sunday, July 4, 2010
今天我们为什么不成功?
1、首先我们没有定义好自己的成功标准是什么(是票子、车子、房子、妻子?),不清楚自己的真正目标,是为了理想、爱好、钱、事业、家庭、权利、欲望、还是人生价值的体现,因此我们每天依旧重复过着糊里糊涂的日子。生活是那么单调、枯燥。
2、我们不清楚已所之长,己所之短,完全不了解自己,到底缺什么、需补什么、擅长什么、有哪些资源,是知识、钱、关系、项目、人脉、还是时势。我们缺乏核心竞争力和不可替代性(即唯一性),所以我们往往不知道该做什么,不该做什么。永远盲目着、彷徨着。
3、我们很容易围着别人转、被别人感染、而不能让别人围着自己转、去感染和影响别人,所以注定了把别人的思想放进自己的脑袋,把自己的钱包放进别人的口袋,自己的命运被别人牢牢把握着,我们的灵魂和思想早被洗窃一空,剩下的只是行尸走肉。既然如此那么我们还能指望自己成就点什么。
4、我们习惯了肤浅的东西,看表面的文章、百般无聊、如出一辙的电视,挂QQ、玩游戏、搓麻将、泡馆子、蹲酒吧、守休闲场所、谈论众说纷纭的炒作新闻等,却少读了几本有价值的书、少见了几个有价值的人,少给了自己几分钟静夜思,严重缺乏看透事物本质的能力。所以我们今天被这个专家、明天被那个大师、后天还有某个名人,前后左右、上上下下、媒体广告、报纸、杂志、电视、网络、轮番轰炸着,在这个混淆视听的环境里,我们缺乏起码的判断力、分析力、概括力、我们往往被迷失了方向,迷失了自我。
5、我们缺乏勇气和魄力,习惯了三点一线的生活,没有了当年的匹夫之勇,不敢走回头路和不归路。我们觉得生活很无奈、工作很单调,发展很受限,却往往詹前顾后,不敢改变自己,懒于学习、不敢做领导、不敢换职位、不敢换工作、不敢创业、不敢质疑、不敢反抗、不敢发表自己的意见、不敢主动交流、不敢创新,因此我们依旧平淡无奇、素然寡味的过平凡人的日子,因为我们人生的旅途缺乏过程、缺乏那种能够品位真正酸、甜、苦、辣的勇气。
6、我们缺乏信任、合作、资源整合,我们总在猜测和矛盾中生活,仍在学着一个人打天下。我们很少拥有真正的朋友、能帮到上忙、借的上钱、铁的了心、有心灵感应时常挂念的朋友、平时不烧香临时抱佛脚,我们不太懂得相互宽容、理解、互补、平衡、分享、互利这些道理,所谓的兄弟、酒肉朋友太多,危难之中,我们可信任的人太少、信任的程度太低、信任的成本太高、我们都在相互猜忌着,力量相互内耗着。我们找不到资源的整合点,其实不会合理利用,仍在感叹我能点做什么,到底怎么办,我们认识的人层次太低,我们的胸怀太狭隘,所以很多道理,真相明白不透,我们默默的做了垫脚石而已。
7、我们缺乏行动力、执行力、做人、处事方法,仍在日复一日,年复一年平淡、懵懂的过日子。我们每时每刻都有美妙的想法,唯独缺没有做法,没有持之以恒的信心和耐力。我们不能时常的照镜子,予以自醒、禅悟。
8、我们缺乏总结力,纠正力,失败了,还是失败了,错误了,依旧错误着。我们的习惯依旧没有改变,由此养成了这种性格,最终决定了这种命运。
9、我们不懂得编织关系网,其实关系网是网状结构,先从你认识和了解的人开始,然后从认识你的人开始,最后从你朋友的朋友开始,依次类推,记得要用心和以诚相待,人与人之间其实是平等的,没有高、低、贵、贱之分(除非你真的有求于他 /她),没有什么了不起的,注意了解他/她人背景和整合资料很重要。
10、我们缺乏理财,常常不知道该买什么,该卖什么,什么是收入,什么是支出,什么是负债,什么是资产,何谓投资,如何开源节流,我们忽视了细节,量变成了质变,因此我们的现金数字依然很尴尬。我们不清楚如何找钱、挣钱、存钱、借钱、还钱、花钱。
11、我们严重缺知识,基础知识+社会知识,即学历太低、经历太少,缺乏不断学习补充、虚心请教、拜师学艺的能力
缺乏海纳百川、中西合璧、文理交融的素质、缺乏一技之长、专攻和全面,我们还是怀着陈旧的思想和笨拙的方法,我们不敢怀疑、挑战、创新新思维。
12、我们早被这个灯红酒绿、物欲横流的世界弄得焦躁不安,不能静下心来,反复,认真的思考自己的人生,稳重走好自己的每一步。我们不懂得管理时间、合理利用时间、守时。以至老大涂伤悲。
13、我们缺乏快乐感、幸福感、安全感,人与人之间太冷漠、太现实,许多家庭支离破碎、许多交际带着有色眼镜,许多圈子旁人所不能及,许多婚姻夹着交易,许多爱情不是爱情,许多亲情缺乏关心、许多兄弟背后插刀、我们害怕房奴、车奴、结婚、生子、生病、失业、人情、意外、整日惶惶,我们不知道什么是快乐幸福,不知道如何寻找、不知道调整自己的心态和位置、不明白取、舍、知足常乐、超越、分享、顺其自然这些东西。
14、我们不懂得把握时势,不懂得政治、经济的厉害关系,不明白风水轮流转、天地合一、互利互惠的道理,不明白红海和蓝海战略,不明白水能载舟亦能覆舟、没有绝对的朋友和绝对的敌人。不懂得顺应潮流和创造潮流,我们依旧固步自封,停滞不前。
15、最后我们看准了方向,做好充分的准备(破斧沉舟),请立即开始行动,坚持、坚持、再坚持!熬过了今天,明天会很美好!其间我们不断的完善自我,调整自我。愿所有有心人能成功!天道酬勤!