查当前目录空间占用
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;
sed 匹配并只输出关键字
echo "asdfasdfasdfwqerwercvmbkjedrt000helloword00aslkdfjalskjdf"|sed -r "s#.*000(.*)00.*#\1#p"
Git一键修改提交信息推送
date +%Y%m%d%H%M >> test.md && git add . &&git commit -m "$(date +%Y%m%d%H%M)" && git push