Maizego Summer Tutorial
Maizego Summer Tutorial
abstraction
Maizego Summer Tutorial
Maizego Summer Tutorial
Lecture 01
)Lecture 01
)Lecture 02
)Lecture 03
)Maizego Summer Tutorial
[CPU], [RAM], [DISK], [I/O]
What scientists must know about hardware to write fast code -- by Jakob Nybo Nissen
Maizego Summer Tutorial
translator
Maizego Summer Tutorial
Maizego Summer Tutorial
# 系统知识: 环境变量, 终端配置 ...
# Bash 常用指令
chmod, setfacl, ls, ln, rm, cp, mv, touch, mkdir, mktemp, cd, rm, find ... # 文件操作,目录操作
vim, cat, less, more, head, tail, wc, sort, uniq, paste, cut ... # 内容操作
sed, awk, grep # Linux三剑客
tar, unzip, gzip, bzip2 ... # 打包/压缩
stdin, stdout, stderr, redirection, pipe, mkfifo, ... # IO与管道
top/htop, ps, kill, free, df, scree, nohup &, ... # 任务管理
alias, xargs, parallel ... # 效率工具
wget, curl, rsyn, scp, sftp, lftp ... # 网络, 同步
# Bash 脚本编程
{...}, "", '', seq, $(), `` # 展开, 转义
a="123.txt"; $a; ${a%.txt}; # 变量赋值和引用, 字符串操作;
if; [ ]; [[ ]]; -a / -o / && / ||; while; for; break; until; case ... #条件判断; 流程控制;
function # 函数: 变量作用域, 函数返回值;
read, readline, echo, printf # 输入输出
# 通配符与正则表达式
Maizego Summer Tutorial
7
test001.txt, test002,txt, ... test100.txt
maize001.tmp, maize002.tmp ... maize100.tmp
Maizego Summer Tutorial
Ctrl+R
; Ctrl+A
; Ctrl+E
; Ctrl+U
; Ctrl+L
;Ctrl+Z
, Ctrl+C
Tab
⬆, ⬇
(can be better: bind '"\e[A": history-search-backward'
,bind '"\e[B": history-search-forward'
)Ctrl + [⬅, ➡]
alias d2u="sed -i 's/\r//g' "
alias u2d="sed -i 's/$/\r/g' "
Maizego Summer Tutorial
${var#*/}; ${var##*/}
${var%/*}; ${var%%/*}
${var:start:len}; ${var:start}; ${var:0-start:len}; ${var:0-start}
${var/pattern/replace}
function cl(){
cd $1 && ls
}
Maizego Summer Tutorial
Test on File Features
-e filename #如果 filename存在, 则为真 [ -e /var/log/syslog ]
-d filename #如果 filename为目录, 则为真 [ -d /tmp/mydir ]
-f filename #如果 filename为常规文件, 则为真 [ -f /usr/bin/grep ]
-L filename #如果 filename为符号链接, 则为真 [ -L /usr/bin/grep ]
-r filename #如果 filename可读, 则为真 [ -r /var/log/syslog ]
-w filename #如果 filename可写, 则为真 [ -w /var/mytmp.txt ]
-x filename #如果 filename可执行, 则为真 [ -L /usr/bin/grep ]
filename1 -nt filename2 #如果 filename1比 filename2新, 则为真 [ /tmp/install/etc/services -nt /etc/services ]
filename1 -ot filename2 #如果 filename1比 filename2旧, 则为真 [ /boot/bzImage -ot arch/i386/boot/bzImage ]
Maizego Summer Tutorial