Shell脚本编程
一、
编写一个Shell脚本 ,接受两个参数 和 ,实现如下功能:
搜索 目录树下的所有 和 文件,如果文件中的某一行中包含 指定的字符串,则将该行内容和
相应的文件名打印出来。
如果 参数缺省,则在当前目录中执行上述针对 的搜索和打印任务。
示例:
or
部分输出结果(格式可以有所不同):
Tips:
Linux提供了 命令用于查找文件中符合条件的字符串,具体用法可以参考:grep 。
你可能也想了解一下Linux的 find 命令用法。
二、
编写一个Shell脚本 ,实现如下功能:
按层次结构输出当前目录树中的所有目录和文件名,每层缩进 个空格。
示例:
输出结果为:
...
/usr/src/linux-headers-4.15.0-136/include/net/dn_dev.h:56: * t2 - Rate limit timer, min
time between routing and hello messages
/usr/src/linux-headers-4.15.0-136/include/net/dn_dev.h:57: * t3 - Hello timer, send hello
messages when it expires
...
评论0