---
title: "俺的linux常用命令技巧"
author: "coderplay"
date: "2008-09-16T12:57:42Z"
tags: []
slug: "linux"
draft: false
lastmod: "2009-02-11T14:10:01Z"
id: 242679
url: "https://coderplay.iteye.com/blog/242679"
---

查找目录dir中后缀为\*.c和\*.h的文件

 

用正则

find dir -type f -name '\*.\[ch]'

 

不用正则

find dir -type f -name '\*.c' -o '\*.h'

 

在目录a下建立目录b,而目录a可能不存在

mkdir -p a/b

 

查看dir目录下面所有txt文件中含有"string"串的总行数

 find dir -type f -name \*.txt -exec grep "string" {} \\; | wc -l

 

 

让所有执器同时执行同一道命令

建立好ssh, 设置环境变量SLAVES指定slaves的地址.

for slave in \`cat $SLAVES\`; do  
 ssh $slave $"${@// /\\\\ }" \\  
   2&gt;&1 | sed "s/^/$slave: /"  
done

 

 

 

slaves.sh scp hadoop@test162.sqa:/home/hadoop/.bash\_profile ~/

slaves.sh scp hadoop@test162.sqa:/home/hadoop/.bashrc ~/

slaves.sh source ~/.bashrc

slaves.sh source ~/.bash\_profile

 

 

 

to be continued...