zoukankan      html  css  js  c++  java
  • N46期第二周作业

    1、在档案中搜寻关键词的命令是( D )。

    A、ps B,eat C、more D、grep

    2、查看⽂件最后100⾏的命令是( tail -100 file )。

    3、实现查询⽂件fifile1⾥⾯空格开始的所在的⾏号?

    grep [^ .*] fifile1 | nl

    4、统计/etc/fstab⽂件中每个单词出现的次数?

    grep -o "[[:alpha:]]+" /etc/fstab | sort | uniq -c

    5、如何查看fifile1⽂件的第300到500⾏的内容?

    head -500 fifile1 | tail -200

    6、shell 脚本编程的主要应用范围有哪些?

    a. 自动化常用命令
    b. 执行系统管理和故障排除
    c. 创建简单的应用程序
    d. 处理文本或文件


    7、 shell 脚本文件的第一行中 #!/bin/bash 的作用是什么?

    指定该脚本由bash shell解释器去执行


    8、编写脚本 hostping.sh,接受一个主机的 IPv4 地址做为参数,测试是否可连通。如果能 ping 通,则
    提示用户“该IP地址可访问”;
    如果不可 ping 通,则提示用户“该IP地址不可访问”。

    vim hostping.sh

    #!/bin/bash
    read -p "IP to Ping? " IP
    ping -c 4 $IP &> /dev/null && echo "IP Reachable" || echo "IP Unreachable"

    Result:

    [16:39:05 root@centos8 ~]#hostping.sh
    IP to Ping? 127.0.0.1
    IP Reachable
    [16:39:16 root@centos8 ~]#hostping.sh
    IP to Ping? 188.188.188.188
    IP Unreachable
    [16:39:37 root@centos8 ~]#

  • 相关阅读:
    Access使用记录
    html js 表单提交前检测数据
    asp.net mvc5 action多个参数
    asp.net mvc Areas 母版页动态获取数据进行渲染
    asp.net mvc 自定义全局过滤器 验证用户是否登录
    .net 报错汇总——持续更新
    数据库基础
    Python协程
    Python 线程
    Python 队列
  • 原文地址:https://www.cnblogs.com/davidwang1970/p/13062371.html
Copyright © 2011-2022 走看看