日志
查找
查看最近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