全部博文(48)
分类: LINUX
2009-12-10 00:51:46
1.Changing working directories
前提条件:
Each command assumes that your working directory is /home/cam just before the command is executed
Command |
New working directory |
cd book |
/home/cam/book |
cd book/wonderland |
/home/cam/book/wonderland |
cd ~/book/wonderland |
/home/cam/book/wonderland |
cd /usr/lib |
/usr/lib |
cd .. |
/home |
cd ../gryphon |
/home/gryphon |
cd ~gryphon |
/home/gryphon |
2.Pathname Expansion
pathname expansion wildcards will expand to files and directories that exist
Pathname Expansion的作用:
将这些wildcards等扩展为“存在的目录或者文件”
Table 1-2. Basic wildcards | |
Wildcard |
Matches |
? |
Any single character |
* |
Any string of characters |
[set] |
Any character in set |
[!set] |
Any character not in set 这个还可以表示成[^set],但是 [!set]不能用在grep或者sed的regex中,因为在grep等的regex中[!set]中的!是一个“表面字符”,而不是一个“特殊字符” |
Table 1-3. Using the * wildcard | |
Expression |
Yields |
fr* |
frank fred |
*ed |
ed fred |
b* |
bob |
*e* |
darlene dave ed fred |
*r* |
darlene frank fred |
* |
bob darlene dave ed frank fred |
d*e |
darlene dave |
g* |
g*(当*号匹配不当任何东西时候,shell会直接把g*这2个字符送到cmd中去) |
如:假如你现在的目录下有个文件叫good.txt,如果你输入vi good.txt
那么vi会打开good.txt这个文件
如果你的现在的目录下没有g字符开头的文件,那么vi就直接新建一个“名字叫g*”的文件
3.Brace Expansion
brace expansion expands to an arbitrary string
brace expansion作用:
扩张为“一个字符串”
例如:
echo begin{1,2,3}end
相等与
echo begin1end begin2end begin3end
{}还可以内嵌
b{ar{d,n,k},ed}s →→→→→→ bards, barns, barks, and beds
以下要在bash的3.0版本以后才有
This form of brace expansion is not available in bash prior to Version 3.0.
{2..5} →→→→→→ 2 3 4 5
{d..h} →→→→→→ d e f g h
4.Background I/O
(1)If a background job produces screen output, the output will just appear on your screen. If you are running a job in the foreground that produces output too, then the output from the two jobs will be randomly (and often annoyingly) interspersed
如果把一个job放在Background 中,而且这个jobs会产生screen output,然后有在当前运行另外一个job,,而且这个job也会产生screen output,那么这2个jobs的output就会随机穿插的显示在stdout中
5.使用bash的help命令
help命令是bash的help命令,而不是其他cmd(工具的)
直接输入help会看到bash内建命令和其他一些信息
help bash内建功能
查看bash内建功能的信息
如:help if help . help % help exit