Linux 实验合集(2)

2019-04-14 10:26

9、恢复被删除的一行内容。 u:取消当前已个动作

10、查找所有的“Minix”并全部改为“MINIX”。

sed 实用工具以及其它任何类似的编辑器的最常用的命令之一是用一个值替换另一个值。用来实现这一目的的操作的命令部分语法是: 's/{old value}/{new value}/'

因而,下面演示了如何非常简单地将 \修改为 \: $ echo The tiger cubs will meet on Tuesday after school | sed 's/tiger/wolf/'

The wolf cubs will meet on Tuesday after school

全局修改

让我们开始一次看似简单的编辑。假定在要修改的消息中出现了多次要修改的项目。默认方式下,结果可能和预期的有所不同,如下所示:

$ echo The tiger cubs will meet this Tuesday at the same time as the meeting last Tuesday | sed 's/Tuesday/Thursday/' The tiger cubs will meet this Thursday at the same time as the meeting last Tuesday $

与 将出现的每个 \修改为 \相反,sed 编辑器在找到一个要修改的项目并作了修改之后继续处理下一行,而不读整行。sed 命令功能大体上类似于替换命令,这意味着它们都处理每一行中出现的第一个选定序列。为了替换出现的每一个项目,在同一行中出现多个要替换的项目的情况下, 您必须指定在全局进行该操作: $ echo The tiger cubs will meet this Tuesday at the same time as the meeting last Tuesday | sed 's/Tuesday/Thursday/g' The tiger cubs will meet this Thursday at the same time as the meeting last Thursday $

文档内修改:

:%s/Minix/MINIX /g(%:所有行 g:所有替换) 11、不保存并退出vi。

q!:exit vi edit(对修改不做保存)

12、使用vi再次打开文件AboutLinux。应该显示原来的两行内容。

13、在第二行后插入一行“He began his work in 1991 when he released version 0.02 and worked steadily until 1994 when version 1.0 of the Linux Kernel was released.”。

14、 在文档的最后增加一行“There are now literally hundreds of companies and organizations and an equal number of individuals that have released their own versions of operating systems based on the Linux kernel.”。 15、保存并退出vi。

16、设置文件AboutLinux的权限为400(“r--------”)。 chmod 400 AboutLinux

17、使用vi再次打开文件AboutLinux,并在文档最后增加一行“More information on the kernel can be found at our sister site, LinuxHQ and at the official Linux Kernel Archives.”。

并保存文档后退出。

五.

1.利用vi 建立一个脚本文件,其中包括date、cal、pwd、ls等常用命令。然后以不同方式执行该脚本. vim script (date cal pwd ls)

(1) bash

Linux 实验合集(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:06090人员素质测评与方法模拟试题与答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: