# Find a file under a directory
$ find ./dir -name "*.h"
# Delete the folders that does not meet name_pattern in the path depth of 1.
$ find { DIR } -mindepth 1 -maxdepth 1 -not -name '{ name_pattern }' -type d -exec rm -rf {} +
# For multiple patterns with `or`,
$ find { DIR } -mindepth 1 -maxdepth 1 \( -not -name "*.py" -o -name "*.html" \) -type d -exec rm -rf {} +
cut
TODO
alias
For example, I want to add alias for Linux WeChat app.
Add following commands to the last line of file ~/.bashrc. (I have an NPM project for electronic-wechat project).
alias wechat="npm start --prefix ~/Develop/WorkSpace/electronic-wechat"
Some useful alias:
alias untar='tar -zxvf '
alias ping5='ping -c 5'
alias www='python -m SimpleHTTPServer 8000'
alias ipe='curl ipinfo.io/ip'
alias ipi='ipconfig getifaddr en0'
alias c='clear'
wc
# Count the lines.
$ ... | wc -l
# Count the bytes.
$ ... | wc -c
# Count the characters.
$ ... | wc -m
# Count the words.
$ ... | wc -w
type
Get the type of a command.
$ type cd
cd is a shell builtin
$ type type
type is a shell builtin
disk/fs related
$ lsblk
$ df -h
$ du -sh
$ du -sh *
$ sudo resize2fs /dev/xvdf
Some common commands and command tools in the Unix-like system.
Basics
netstat
netstat 命令用于显示各种网络相关信息,如网络连接, 路由表, 接口状态等等
refs: 腾讯云实验室
tar
tar 是一个简单的解压缩工具。其中tar后缀代表只是把文件打包在一起,gz后缀代表压缩。
c代表compress; z代表gzip的压缩包; x代表extract; v代表显示过程信息; f代表后面接的是文件.
scp
Suppress all logs
find
cut
TODO
alias
For example, I want to add alias for Linux WeChat app. Add following commands to the last line of file
~/.bashrc
. (I have an NPM project for electronic-wechat project).alias wechat="npm start --prefix ~/Develop/WorkSpace/electronic-wechat"
Some useful alias:
wc
type
Get the type of a command.
disk/fs related
date
kill a process by name