linux command learn tips

awk强大的文件操作,从Alfred Aho,Peter Weinberger and Brain Kernighan
找出非系统产生的账号:

awk -F “:” ‘($3 >= 1000) { printf $1 “\n”}’ /etc/passwd
awk Pattern {ACTIONS;}

awk中仅有string和numeric,可以互相转换。
文件中每一行check每一种pattern(Regex,Boolean,Special),In Boolean Search,进行fuzzy matching,” 23”==23

ack, awk, grep

git 25 tips useful But a little long

查看当前服务器的运行级别。

runlevel
who -r

找到/usr下面大于10M的文件,找到120天之前被修改过的文件. 找出90天内未被访问过的文件。

find /usr -size +10M
find /home -mtime +120
find /home \! -atime -90

alias 设置别名,方便以后使用。

alias ls=ls -al

工作流程控制的几个命令:

jobs [-lp] [job]
bg [job]
fg [job]
kill [-signal] job..
wait [job..]
%number: refer to job by number
%string: job whose name begins with string
%?string: job whose name contains string
%+ or %%: current job
%-: previous job
bg show all jobs in the backend
fg %2 put the 2 in the front
jobs show all jobs

ENV NAME MEANING
$HISTCMD the history number of the current command
$HISTSIZE number of remembered commands
$HOME login directory
$MAIL absolute path of mailbox
$OLDPWD absolute path of previous directory
$PATH command search path
$PPID process ID of parent
$PS1 primary prompt 1
$RANDOM generate random number
$SECONDS number of seconds since shell started
$SHELL absolute path of shell
$UID user ID of the current user
$$ process ID of current shell
$? exit status of most recent statement
$# number of the argruments
$x all the arguments
$! PID of the moust recent background job

shell if 语句,testing[]里面是判断,-a是and,-o是or,-e是equal,-z是zero,-n不是zero

if [ $DEBUG -eq 1]; then
elif [ -f /etc/passwd ]; then
else
fi