linux shell命令匹配并获取下一行数据(awk,sed,grep)

正则表达式和grep用法,及文本查看、处理工具

https://www.sohu.com/a/199364326_470018

grep及正则表达式

https://blog.51cto.com/kusorz/1826899

grep 常见用法

https://zhuanlan.zhihu.com/p/92835265

去除空行和_(_123输出123)  grep -o '[^_]*$'

去除空行和#开头的行 grep -vE '^$|^#'

去除空白行或“所有空白”的文件(例如带有\ r \ n样式行结尾的窗口行) grep -v -e '^[[:space:]]*$'

 grep -Hrn 'cluster_block_exception' /opt/tm-api/logs/*

文件名:行号:内容

 

Sed

a.txt

mmnBB

cD LKo

oL

$ sed -r 's/([a-z0-9])([A-Z])/\1 \2/g' a.txt

mmn BB

c D LKo

o L

 

 

linux shell命令匹配并获取下一行数据(awk,sed,grep)

https://blog.csdn.net/cbuy888/article/details/105413623

 elasticsearch.yml


cluster.name: xx-elk

network.host: 0.0.0.0

node.master: true
node.data: true

bootstrap.system_call_filter: false

path:
logs: /opt/elasticsearch6/logs
data: /var/data/elasticsearch6
 

 

ES_DATA_PATH_LINE=`grep "^  data: " "$ARTIFACT_DIR/services/elasticsearch6/elasticsearch.yml"`
ES_DATA_PATH=`echo $ES_DATA_PATH_LINE | cut -d ':' -f 2 | awk '{printf $0}'`

 

ARTIFACT_DIR='/opt/udeployha/agent/var/work/CMT - Rates - Apache Storm/storm'
ES_DATA_PATH_FILE=$ARTIFACT_DIR/services/elasticsearch6/elasticsearch.yml
ES_DATA_PATH=`cat "$ES_DATA_PATH_FILE" | sed -n '/path:/,${/^  data:/{s/  data: //p}}'`

 

linux中联合ps -ef与kill -9杀掉进程

ps -ef | grep logs-disposal.sh | grep -v grep | awk '{print $2}' | xargs kill -9

find /opt/apache-storm/logs/workers-artifacts -maxdepth 3 -type f -name "*.gz" | xargs ls -lrt | head -40 2> /dev/null
du -sh /opt/apache-storm/logs/workers-artifacts

grep -Hrn 'cluster_block_exception' /opt/tm-api/logs/* | head 

grep -Hrn 'OutOfMemoryError' /opt/apache-storm/logs/workers-artifacts/* | head

df -Ph
du -ah /var/data 2> /dev/null | sort -rh | head -10

posted @ 2020-07-29 19:46  tonggc1668  阅读(2870)  评论(0编辑  收藏  举报