Last active
October 11, 2019 14:11
-
-
Save kevinclcn/182f1e7f0ea2eb2a0db4579d9ddff796 to your computer and use it in GitHub Desktop.
shell使用技巧
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 遍历一个数字范围, https://stackoverflow.com/questions/169511/how-do-i-iterate-over-a-range-of-numbers-defined-by-variables-in-bash | |
for i in $(seq 1 $END); do echo $i; done | |
# 枚举多台机器上的java堆栈 | |
for i in $(seq 204 231); do ssh 192.168.12.$i "ls -lh /opt/log/stash/customer/java_pid1.hprof"; done | |
# 使用sed做替换 | |
gsed -i -e 's/\(FROM .*alpine-openjdk8[^:]*\)$/\1:8u221/g' */*/Dockerfile | |
# 使用ruby处理json行, 并设定encoding | |
ruby -n -r json -e "BEGIN {ARGF.set_encoding('gb2312')}" -e 'j=JSON.parse($_); puts "#{j["identityCustomerId"]}, #{j["attr"]["attr3"]}"' registerStore_attr3.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment