简单面试题

sh/bash/dash/ksh/zsh等Shell脚本
回复
flyinflash
帖子: 2376
注册时间: 2006-09-21 14:28

简单面试题

#1

帖子 flyinflash » 2008-10-13 16:20

某目录a下有n个文件和子目录,文件里面有(可能没有) x_to_local_lang('x') 字符串。
现在需要把所有文件内的 x 抓出来,合成一个元素唯一性的数组,最后存进文件i18n.txt。

我的思路:
scan file with -r
catch x_to_local_lang('x') as $i18n['en_us'][x], include $__file__, $__line__
shift $i18n['en_us'][x], >> i18n.txt

可是,脚本我竟然写不出来…… :em06 :em06 :em06
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 简单面试题

#2

帖子 oneleaf » 2008-10-13 16:38

grep -r -h -o -E ... . | awk ... | uniq > xxx
头像
Jarson
帖子: 2371
注册时间: 2008-07-21 9:44
来自: 深圳
联系:

Re: 简单面试题

#3

帖子 Jarson » 2008-10-13 17:08

顶,老大就是强!
回复