Bash 递归grep

grep pattern -r directory *.txt

Bash 复制目录(unix)

cp -R /verzsource/ /target

Bash 在OSX上获取WLAN上的信息

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk '/avg/ || / SSID/ {printf $0 }' | awk '{ print "WLAN : " $6 ", S/N " $2 "/" $4 }'

Bash 下载y转换视频de YouTube

#!/bin/bash

if [ $# -lt 1 ]; then
echo "Uso: $0 "
exit 1
fi

ID=`echo $1 | cut -d= -f2 | cut -d\& -f1`
FILE="youtube-${ID}"
BASE_URL="http://youtube.com/get_video.php"

wget -O /tmp/${FILE} $1

if [ $? == 0 ]; then
T_PARAM=`grep '&t=' /tmp/${FILE} | head -n 1 | awk -F'&t=' '{print $2}' | cut -d\& -f 1`
VIDEO_URL="${BASE_URL}?video_id=${ID}&t=${T_PARAM}"

wget -O ${FILE}.flv $VIDEO_URL

if [ $? != 0 ]; then
rm -f ${FILE}.flv
exit 1
else
echo "Formato (avi , mpg o wmv): "
read formato
ffmpeg -i ${FILE}.flv ${FILE}.$formato
fi
fi

rm -f /tmp/${FILE}

Bash 在vim中编辑命令输出

vim `find . -name \*.html -exec grep -l get_admin_url {} \;`

Bash 在subversion下为文件设置可执行权限

svn propset svn:executable ON filename

Bash shopt(外壳选项)

// display all shell options with their status
shopt

// display only set (on) options
shopt -s

//display only unset (off) options
shopt -u

//set (turn on) an option
shopt -s foo

//unset (turn off) an option
shopt -u bar

Bash 查看svn中每个目录的提交/修订数量

for file in *; do echo "$file: "; /usr/bin/svn log -q $file |  grep 'r[0-9][0-9]*' | wc -l; done

Bash 计算目录中的htm / html文件(递归)

ls -R | grep -c '.htm'

Bash 使用curl在命令行上进行LDAP / NTLM身份验证

curl --ntlm -u user:pass http://mysite.com