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
| if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) { | |
| // path/to/whatever does not exist | |
| } | |
| if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) { | |
| // path/to/whatever exists | |
| } |
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
| # 不断显示出文件最新内容 | |
| tail -f xx.log |
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
| import traceback | |
| def f(): | |
| for line in traceback.format_stack(): | |
| print(line.strip()) |
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
| for i in `ps -ef --no-headers | awk '{ print $2; }'`; do | |
| sudo cat /proc/$i/environ | \ | |
| tr '\0' '\n' | | |
| grep '\.utf8$' > /dev/null 2>&1 && echo $i | |
| done > /tmp/123 | |
| ps -ef | grep -P "$(tr '\n' '|' < /tmp/123 | sed 's/\|$//')" | |
| rm /tmp/123 |
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
| # ensure_ascii 设为假可以打印中文。indent 是缩进 | |
| print(json.dumps(obj, indent=4, ensure_ascii=False)) |
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
| XX=${YY:-ZZ} # ZZ 是 YY 没设置时使用的默认值 |
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
| sftp [email protected] | |
| put localpath | |
| get remotepath | |
| ---- | |
| scp local_file remote_user@host:remote_folder |
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
| export i=1; while true; do export i=$((i+1)); echo $i; sleep 1; done; |
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
| # 2 means the second argument | |
| my_variable=${2:-"default value"} | |
| # Use the second argument, but if none then the first one | |
| my_another_var=${2:-${1}} |
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
| sed -e '/指定内容/d' old.log > new.log |
NewerOlder