基本 Unix 命令 - abstract:
file foo: 显示foo文件的属性。
type commandname: 显示命令 commandname的信息。
apropos key-word: 找到和key-word相关的命令。man -k key-word也可以。
whatis commandname: 显示commandname的一句话帮助。
lsof foo: 显示文件foo的打开状态。
cd: 切换到用户主目录。
cd -: 切换到上一次所去的目录。
touch junkfile: 创建一个空文件junkfile。
mv foo bar: 把已有的foo文件重新命名为bar。
grep -e "pattern" *.html: 找到当前目录下面所有以.html结尾的文件中含有"pattern"的行,并显示它们。
Shell 通配符
* 这个匹配0个或者多个字符。
它不会匹配以"."开始的文件名.
? 这个仅匹配一个字符。
[...] 这个匹配[]里面的某个字符。
[a-z] 这个匹配字符a到z之间的某个字符。
[^...] 这个匹配任意不包含在[]里面的字符(不包含字符"^").
example:
$ mkdir junk; cd junk; touch 1.txt 2.txt 3.c 4.h .5.txt
$ echo *.txt
1.txt 2.txt
$ echo *
1.txt 2.txt 3.c 4.h
$ echo *.[hc]
3.c 4.h
$ echo .*
. .. .5.txt
$ echo .[^.]*
.5.txt
$ echo [^1-3]*
4.h
$ cd ..; rm -rf junk
file foo: 显示foo文件的属性。
type commandname: 显示命令 commandname的信息。
apropos key-word: 找到和key-word相关的命令。man -k key-word也可以。
whatis commandname: 显示commandname的一句话帮助。
lsof foo: 显示文件foo的打开状态。
cd: 切换到用户主目录。
cd -: 切换到上一次所去的目录。
touch junkfile: 创建一个空文件junkfile。
mv foo bar: 把已有的foo文件重新命名为bar。
grep -e "pattern" *.html: 找到当前目录下面所有以.html结尾的文件中含有"pattern"的行,并显示它们。
Shell 通配符
* 这个匹配0个或者多个字符。
它不会匹配以"."开始的文件名.
? 这个仅匹配一个字符。
[...] 这个匹配[]里面的某个字符。
[a-z] 这个匹配字符a到z之间的某个字符。
[^...] 这个匹配任意不包含在[]里面的字符(不包含字符"^").
example:
$ mkdir junk; cd junk; touch 1.txt 2.txt 3.c 4.h .5.txt
$ echo *.txt
1.txt 2.txt
$ echo *
1.txt 2.txt 3.c 4.h
$ echo *.[hc]
3.c 4.h
$ echo .*
. .. .5.txt
$ echo .[^.]*
.5.txt
$ echo [^1-3]*
4.h
$ cd ..; rm -rf junk