date正则一例
[root@www 10.54.30.152_dir]# date -d "1970-1-1 0:0:0 GMT + 1318484041 seconds" | sed 's#^([0-9]*).* ([0-9]*).* ([0-9]*).* .* ([0-9]*:[0-9]*:[0-9]*) [A-Z]*$#1-2-3 4#'2011-10-13 13:34:01[@more@]
Code:软件安装程序模板
#!/bin/bash# install lighttd# author chunsheng1@staff.sina.com.cn# last update 2011-09-21YASM_NAME="yasm-1.0.1"YASM_SUFFIX=".tar.gz"JPEG_NAME="jpegsrc.v8c"JPEG_SUFFIX=".tar.gz"FFMPEG_NAME="ffmpeg-0.8.1"FFMPEG_SUFFIX=".tar.gz"PCRE_NAME="pcre-7.4"PCRE_SUFFIX=".tar.gz"LIGHTTPD_NAME="lighttpd-1.4.18_sina-5.0"LIGHTTPD_SUFFIX=".tgz"TRANSFER_RSYNC_MODULE=$1"::download/video/"LIGHTTPD_INSTALL_DI
shell 笔试题
shell 笔试题[@more@]hell 实例1.查找当前目录中所有大于500M的文件,把这些文件名写到一个文本文件中,并统计其个数。find ./ -size +500M -type f | tee file_list | wc -l2.在目录/tmp下找到100个以abc开头的文件,然后把这些文件的第一行保存到文件new中。for filename in `find /tmp -type f -name "abc*"|head -n 100`dosed -n '1p' $filename>>newdone3.把文件b中有的,但是文件a中没有的所有行,保存为文件c,并统计c的行数。grep -xvf a b | tee c | wc -l4.判断一文件是不是块或字符设备文件,如果是将其拷贝到
awk 习题
awk 习题[@more@]1.使用:符号做分隔符,将字段逆序输出/etc/passwd文件的每行[root@ pub]# awk -F: '{for(i=NF;i>1;i--) printf "%s:",$i;print $i}' /etc/passwd2.# awk -F: 'NR < 11 {print $3,$1}' /etc/passwd > name.txt# awk -F: 'NR < 11 {print $3,$6}' /etc/passwd > home.txt# join name.txt home.txt 观察两个文件,以及join命令输出,用awk引入name.txt,home.txt两个文件,模拟joni命令的输出[root@ awk]# awk '{ary[$1]=NR==FNR?$2:ary[$1]" "$2}END{for(i in ary) print i,ary[i]}' name.tx
Perl脚本 杂记
Perl脚本 杂记[@more@]Perl脚本:Perl chdir函数2010年10月29日 星期五 下午 16:24用法:chdir EXPRchdir介绍:如果可能,chdir函数改变当前进程的工作目录到EXPR。如果省略EXPR,即返回调用者的根目录。成功时返回真,否则返回假。例子:假设根目录/home/zhenglc:#!/usr/bin/perlchdir "/usr/home";# Now you are in /usr/home dir.chdir;# Now you are in home directory /home/zhenglc又或者是用perl的单行命令:perl -e 'chdir; print `pwd`'#输出:/home/zhenglcperl -e 'chdir "/home/zhenglc/temp/"; print `p
awk 用法杂记
awk 用法杂记[@more@]awk '{if($1=="'user3'") {print $1,$2,$3;exit}}' file|while read a b c 这样可以通过read读来自管道传过来的信息。