ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Linux可复用命令行

2021-08-20 20:00:56  阅读:49  来源: 互联网

标签:grep #. 复用 echo json sed 命令行 Linux print


查当前目录空间占用

du -h --max-depth=1

查IP地址

ifconfig $(route -n |grep ^0.0.0.0|awk '{print $8}')|grep -E "inet\s+"|awk '{print $2}'|sed -r "s#.*:([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*#\1#g"

查Linux版本号

cat /etc/redhat-release |sed -r "s#.*release ([0-9]\.[0-9])\.?[0-9]{0,5}.*#\1#g"

调Python解析json

cat ./demo.json |python -c "import json,sys; obj=json.load(sys.stdin); print(''.join(i['value'] + ' ' for i in obj['menu']['popup']['menuitem'] if i['value']));"

查Java进程端口

echo;if [[ ! $(whoami) == "root" ]]; then echo "[WARNING] Please use root";fi;echo;echo "==========";oldifs="$IFS";IFS=$'\n';for i in $(ps -ef|grep -v grep|grep java);do echo -n -e "PID :\t";echo $i|awk '{print $2}';echo -n -e "NAME:\t";echo $i|sed -r "s#.* (.*\.jar).*#\1#g";echo -n -e "PORT:\t";echo $(ss -ntlp|grep $(echo $i|awk '{print $2}') |sed -r "s#.*::.*:([0-9]{3,5}).*#\1#g");done;IFS=$oldifs;echo "==========";echo;

标签:grep,#.,复用,echo,json,sed,命令行,Linux,print
来源: https://www.cnblogs.com/jrri/p/15168003.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有