Linux运维相关命令(不定时更新)

日志

查找

查看最近n行

>>> tail -n 100 filename

查找包含字符’a’的行

>>> grep a filename

修改

删除包含字符’a’的行

>>> sed -i -e '/a/d' filename

批量修改文件名(去掉某字符串)

比如目录下有如下文件

a_syncing.json
b.json
c_syncing.json
d_syncing.json

我们希望去掉文件中的’_syncing’

a.json
b.json
c.json
d.json
>>> for file in `ls form_config/*.json`;do mv $file `echo $file|sed 's/_syncing//g'`;done;

参考:https://blog.csdn.net/zhuhai__yizhi/article/details/76619233

进程

批量结束进程

比如你用multiprocessing开了好多的进程,希望将这些进程结束,如果一个一个kill会非常慢

root       120    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       121    71 62 16:06 pts/0    00:00:38 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       122    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       123    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       124    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       125    71 57 16:06 pts/0    00:00:35 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       126    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       127    71  1 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       128    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       129    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       130    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       131    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       132    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       133    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       134    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       135    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       136    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       137    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n
root       138    71  0 16:06 pts/0    00:00:00 python3 full_sync.py -n y -all y -arc n -cbucket n -oss n

我们可以使用pkill

>>> pkill -9 python3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值