Linux 操作系统基础教程.pdf

上传人:asd****56 文档编号:70341363 上传时间:2023-01-19 格式:PDF 页数:11 大小:254.46KB
返回 下载 相关 举报
Linux 操作系统基础教程.pdf_第1页
第1页 / 共11页
Linux 操作系统基础教程.pdf_第2页
第2页 / 共11页
点击查看更多>>
资源描述

《Linux 操作系统基础教程.pdf》由会员分享,可在线阅读,更多相关《Linux 操作系统基础教程.pdf(11页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Linux操作系统基础教程操作系统基础教程 提到Linux操作系统,就不能不提UNIX和GNU。UNIX是由AT&T Bell实验室于1969年开发的多用户、多任务操作系统,是目前广泛使用的商业操作系统。而GNU则开始于1984年,Richard Stallman发起的GNU计划,目的是为了创建一套完全自由的操作系统(GNU宣言)。GNU是“GNUs Not Unix”的递归缩写。(通用公共许可GNU General Public License,GPL,反版权copyleft,自由软件基金会Free Software Foundation,FSF)。1991年,Linus Torvalds编

2、写了与UNIX兼容的LINUX操作系统并在GPL条款下发布。1992年,Linux与其他GNU软件结合,产生了完全自由的操作系统,所以Linux操作系统又被称为“GNU/Linux”。三大主流三大主流shell 查看文件/etc/shell,可列出操作系统所包含的shell Bourne shell也称sh,是Version 7 Unix默认的Unix Shell。Bourne Again Shell 多数Linux操作系统的默认shell,是Bourne shell(UC Berleley)的扩展,是Bourne again/Born again shell的双关语,1987年由Brian

3、Fox创造。C shell,TC shell模仿C的语法,开发与BSD系统,脱胎于第六版UNIX的/bin/sh,也是Bourne shell的前身,加入了alias,command history等功能。Korn shell是第一个UNIX shell,它完全向上兼容Bourne shell并包含了许多C shell的特性。查看用户的默认shell,请查看文件/etc/passwd 每个进程都有一个进程号pid,可用pstree或者ps ef命令查看 1.常用常用Linux命令命令(1)uname(2)ls(3)ps(4)date 讯猴百度文库批量上传下载全能助手 http:/ 2.C Sh

4、ell 1.shbang line#!/bin/csh 或者#!/bin/tcsh ments#this is comment line 3.wildcards 4.5.local variables set variable=value set tom=”tom”6.global variables setenv variable value setenv tom tom 7.extract the variable value echo$variable_name echo$name echo$PRINTER 8.user input echo“what is your name?”set

5、 name=$,=,=,=,=14.conditional statements 15.loops 16.functions function_name()block of code function function_name block of code 6.regular expression and pattern matching 正则表达式与模式匹配正则表达式与模式匹配 1.regular expression definition:a regular expression is just a pattern of characters used to match the same

6、characters in a search.讯猴百度文库批量上传下载全能助手 http:/ if we want to substitute“Tom”or“tom”in the text to“admin”,how?vi里面寻找包含”tom”的行:/tom/,如果只是简单的寻找,一方面无法找到Tom,另一方面还会找到stomachache、tommorrow以及tomatoes等。因此需要比较复杂的正则表达式的应用。:1,$s/admin/g即可完成替代 其中1,$表示从第一行到最后一行 s表示取代(substitute)Tt表示字母”T”或者”t”的其中一个 表示一个单词的结束,这里不一定

7、是同一个单词 /g表示全局取代 2.metacharacter元字符元字符 Beginning of line anchor/love/Matches all lines beginning with love$End of line anchor/love$/Matches all lines ending with love.Matches one character/l.e/Matches lines containing an l,Followed by two characters*Matches zero or more of the preceding/*love/Matches

8、 lines with zero or more spaces,followed by the pattern love Matches one in the set/Llove/Matches line containing love or Love x-y Matches one character within range from x to y/A-Zove/Matches letters from A through Z followed by ove Matches one character not in the set/A-Z/Matches any character not

9、 in the range between A and Z Used to escape a meacharacter/love./Matches lines containing love,followed by a literal period;normally the period matches a single any character Beginning of word anchor/End-of-word anchor/love/Matches lines containing a word that Hi Tom,I think I failed my anatomy tes

10、t yesterday.I had a terrible stomachache.I ate too many fried green tomatoes.Anyway,Tom,I need your help.Id like to make the test up tomorrow,but dont know where to begin studying.Do you think you could help me?After work,about 7 PM,come to my place and Ill treat you to pizza in return for your help

11、.Thanks.Your Pal,guyphantom 讯猴百度文库批量上传下载全能助手 http:/ with love(supported by vi and grep)(.)Tags match characters to be used/(love)able 1er/May use up to nine tags,starting with the first tag at the leftmost part of the pattern xm or xm,or xm,n o5,10 Matches if line contains between 5 to 10 consecutiv

12、e occurrence of the letter o(supported by vi and grep)example:/love/love$/l.ve/中,dot(.)匹配除了换行符之外的任意字符,如live/love/leve/lave/o*ve/中,asterisk(*)匹配0个到多个前一个字符o,包括ve/ove/oove/Llove/匹配love/Love/ovea-z/匹配ovea/oveb/ovez/oveA-Za-z0-9/匹配与ove紧跟的字符不是大写、小写字母和数字,例如”ove“(空格)3.更为复杂的元字符更为复杂的元字符 /A-Z.$/匹配大写字母开始,长度为3个字

13、符的行/A-Za-z*30-5/大写字母开始,紧跟0个或多个小写字母或空格,再紧跟数字3和0-5之间数字的行/*A-Za-za-z$/匹配0个到多个空格开始,后面紧跟一个大写字母和两个小写字母的行/a-z*./匹配包含0-多个小写字母,后面紧跟句号的行/A-Za-z*,A-Za-z*$/呢?4.more regular expression I had a lovely time on our little picnic.Lovers were all around us.It is springtime.Oh love,how much I adore you.Do you know the

14、 extent of my love?Oh,by the way,I think I lost my gloves somewhere out in that field of clover.Did you see them?I can only hope love is forever.I live for you.Its hard to get back in the groove.Christian Scott lives here and will put on a Christmas party.There are around 30 to 35 people invited.The

15、y are:Tom Dan Rhonda Savage Nicky and Kimberly Steve,Suzanne,Ginger and Larry.讯猴百度文库批量上传下载全能助手 http:/ textfile Unusual occurrences happened at the fair.Patty won fourth place in the 50 yard dash square and fair.Occurences like this are rare.The winning ticket is 55222.The ticket I got is 54333 and D

16、ee got 55544.Guy fell down while running around the south bend in his last event.在每一行查找单词fourth 查找以f开始的单词,后面紧跟0-多个字符,最后是”th”的字符串的行 将所有occurence 和 Occurence 修改为occurrence和Occurrence:1,$s/(Ooccur/)ence/1rence/g 颠换短句”fair and square”中的单词fair 和 square:1,$s/(fair)and(square)/2 and 1/g 查找包含连续两个5,紧跟3个2,后面是

17、句号:1,$/5223./5.grep family继续巩固正则表达式:来源于继续巩固正则表达式:来源于ex编辑器编辑器 grep是常用的查找pattern的命令 ex编辑器编辑器:/RE/p 打印包含pattern的第一行:g/RE/p 打印所有包含pattern的行 工作模式工作模式 在一个或多个文件中查找多个字符模式,如果存在空格,模式必须用引号 用法用法 grep word filename1 filename2 如在/etc/passwd中查找admin这个用户:grep admin/etc/passwd 常用于管道,例如ps ef|grep bash grep选项列表 Option

18、s What it does-b 找到匹配的位置在行前输入block number-c 输出匹配行的数目,而不输出结果-h 不显示文件名-i 不考虑匹配字母的大小写-l 列出具有匹配行的文件名称,用分行符分割-n 在前面输出行号,紧跟该行内容-s Silently没有输出,除非有错误产生,用来检查退出状态,找到返回0,找不到模式退出状态为1,找不到文件报错退出状态为2;可用echo$?检查状态-v Inverts,仅仅输出不匹配的行-w 查找表达式作为一个单词,把它视作内部 讯猴百度文库批量上传下载全能助手 http:/ grep NW datafile grep NW d*grep n da

19、tafile grep 4$datafile grep TB Savage datafile grep 5.datafile grep.5 datafile grep we datafile grep 0-9 datafile grep A-ZA-Z A-Z datafile grep ss*datafile grep a-z5,9 datafile grep north datafile grep datafile grep a-z.*n datafile grep n south datafile grep i pat datafile grep v Suan Chin datafile

20、grep v Suan Chin datafile tempfile mv temp datafile grep l SE*grep c west datafile grep w north datafile ls l|grep d rpm qa|grep http metacharacter+matches one or more of the preceding character a-z+ove?matches zero or one of the preceding character lo?ve a|b matches either a or b love|hate()group c

21、haracters love(able|ly)(ov)+egrep egrep +file prints lines beginning with one or more spaces egrep *file prints lines beginning with zero or more spaces egrep(Tom|Dan)Savage prints lines containing Tom Savage or Dan Savage egrep(ab)+file prints lines with one or more occurrences of ab egrep X0-9?pri

22、nts lines beginning with X followed by 0-1 single digit fgrep:fixed grep,does not recognize any regular expression metacharacters as being special.grep R recursively descend a directory tree rgrep 讯猴百度文库批量上传下载全能助手 http:/ GNU grep grep pattern filename 基本方式 grep G pattern filename 基本方式 grep E pattern

23、 filename 扩展RE元字符 grep F pattern filename 无RE元字符,同fgrep grep P pattern filename 理解为Perl-RE w 表示a-zA-Z0-9_ W 表示a-zA-Z0-9_ b 表示边界,例如bloveb匹配单词love egrep NW|EA datafile grep E NW|EA datafile grep NW|EA datafile grep NW|EA datafile egrep 3+datafile grep E 3+datafile grep 3+datafile egrep 2.?0-9 datafile grep E 2.?0-9 datafile grep 2.?0-9 datafile grep V显示版本号 grep-2 显示pattern的前后两行 grep C 2 前后两行 grep A 2 后面两行 grep B 2 后面两行 讯猴百度文库批量上传下载全能助手 http:/

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁