@mSolo
2015-05-20T13:17:16.000000Z
字数 1652
阅读 1252
Linux
Vim
export CDPATH=.:~:/etc:/var
alias cd4="cd ../../../.."
function mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
# grep John /etc/passwd
jsmith:x:1082:1082:John Smith:/home/jsmith:/bin/bash
jdoe:x:1083:1083:John Doe:/home/jdoe:/bin/bash
# grep -v John /etc/passwd
jbourne:x:1084:1084:Jason Bourne:/home/jbourne:/bin/bash
# grep -c John /etc/passwd
2
# grep -cv John /etc/passwd
39
# grep -i john /etc/passwd
jsmith:x:1082:1082:John Smith:/home/jsmith:/bin/bash
jdoe:x:1083:1083:John Doe:/home/jdoe:/bin/bash
# grep -ri john /home/users
/home/users/subdir1/letter.txt:John, Thanks for your contribution.
/home/users/name_list.txt:John Smith
/home/users/name_list.txt:John Doe
$ grep "^Nov 10" messages.1
Nov 10 01:12:55 gs123 ntpd[2241]: time reset +0.177479 s
Nov 10 01:17:17 gs123 ntpd[2241]: synchronized to LOCAL(0), stratum 10
# find /etc -name "*mail*"
# find / -type f -size +100M
# find . -mtime +60 # 60 day
# find /home/jsmith -type f -mtime +60 | xargs tar -cvf /tmp/`date '+%d%m%Y'_archive.tar`
$ cat employee.txt
100 Jason Smith
200 John Doe
300 Sanjay Gupta
400 Ashok Sharma
$ cat bonus.txt
100 $5,000
200 $500
300 $3,000
400 $1,250
$ join employee.txt bonus.txt
100 Jason Smith $5,000
200 John Doe $500
300 Sanjay Gupta $3,000
400 Ashok Sharma $1,250
find ~ -name ‘*.log’ -print0 | xargs -0 rm -f
Execute Commands in the Background with logout
$ nohup ./my-shell-script.sh &
输出到屏幕的同时也输出到文件
$ cat Example.txt |tee e2.txt
$ script -a example.txt
、$ exit
/\%>12l\%<24lsearch
,来源600000 浦发银行
:1,$s/\(\d\+\)\(\D\+\)/\1/g
000042 中证财通可持续发展100指数
: 1,$s/\(^.\{6\}\).*/\1/g