与文件有关的命令
删除当前文件夹下某种类型的文件
find . -type f -name
"*.html" |xargs rm
find . -type f -name
"*.html"|
while read line;
do echo $line;rm
$line;
done
统计当前文件夹下某种类型的文件的个数
find . -type f -name
"*.json" |wc
-l
ls *.json|wc
-l
测试过,find命令时间更短。推荐。
查找文件夹下含有某个字符串的文件 find -type f -name '*.php'|xargs grep 'GroupRecord'
复制大量数据,用cp参数列表过长
find
. -name "*.html" -exec cp {}
../../../wanfang/get_all_url/res/
data/ \;
统计文件夹下文件的个数
ls
-l |grep
"^-"|wc
-l
查看正在写入的文件
tail
-f filename
tail filename
more filename
head -n
10 filename
统计文件行数
cat file | wc
-l
文件中强制输出tab健^I
ctrl + v +
i
输出重定向到文件
python work
.py > temp
.txt #把work.py中的print输出全部输出到temp.txt文件
进程 相关
查看当前有多少在后台运行的命令
jobs
查看当前运行的进程
ps -ef |grep run
.sh (其中run
.sh是启动的程序)
后台运行程序
nohup sh -
x run
.sh & (输出日志在nohup
.out)
screen启动另一个屏幕运行程序
screen -R wj
Ctrl +
a + d
screen -S wj -X quit
发送邮件
mail -s
"邮件题目" aa@baidu
.com -c cc@baidu
.com < mail
.txt
#-c 后面是抄送的邮件
#发送的内容是 mail.txt 里面的内容