ITeye博客

2009 年文章归档

共 3 篇文章

UNIX: Some useful commands

To search a string from the content of files. E.g. Search 'logo.gif' from all jsp,html and xsl files under current folder find . \( -name '*.jsp' -o -name '*.html' -o -name '*.xsl' \) -exec grep -l logo.gif {} \; To get lines in a certain range from file which is huge E.g. Get the lines from 20 to …

2009-08-26 12:05 · shell

UNIX: DOS To UNIX

Features: Convert window format to UNIX format Keep the last modify date of file unchanged if [ $# -ne 1 ];then echo echo "USAGE: $0 fileName" echo exit -1 fi file=$1 tr -d '\r' <$file >$file.tmp touch -r $file $file.tmp mv $file.tmp $file chmod 777 $file

2009-08-26 11:58 · shell

UNIX: Get the date of N days ago

Here is a real practice: House keep log files which have been out of date for N days. if [ $# -ne 2 ];then echo "Usage: $0 [develop|uat|prod] [ n days ago ]" exit -1 fi ENV=$1 N_DAYS_AGO=$2 function getDays { _thisMon=$1 _thisYear=`date +%Y` _div4=`expr $_thisYear \% 4` _div100=`expr $_thisYear \% …

2009-08-26 11:51 · shell