LINUX 作业一(2)

    xiaoxiao2021-03-25  136

    shell 使用

    如何执行脚本

    输入重定向 bash/sh < script-file脚本名直接做参数(常用) bash/sh script-file脚本权限设置为可执行(此时脚本目录应包含在PATH中) chmod a+x script-file PATH = $PATH:.script-file

    注释

    使用#进行文本的注释 在开头用#!/bin/bash定义执行方式 #!/bin/bash


    find /home -type d -print > ls.txt — 使用find找到/home目录下类型为d(就是所有目录),然后输出重定向到 ls.txt

    find /home –type d –print > log_($user)_($date +%Y)_($date +%m)_($date +%d) — 先用 find –help查看find命令内容 — 其中, type 后面是参数, d是目录,f是文件,用>重定向输出,后面调用参数分别表示用户,时间

    shell 代码:

    执行结果

    获取到的内容

    转载请注明原文地址: https://ju.6miu.com/read-9144.html

    最新回复(0)