您的位置:首页 > 运维架构 > Shell

基本 Unix 命令 - abstract

2007-10-01 15:12 246 查看
基本 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

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unix shell file