zoukankan      html  css  js  c++  java
  • shell脚本


    1.1 Shellshell脚本

    Shell是用户与linux系统内核进行联系的桥梁。Linux 通过shell界面,接受用户的请求,利用系统资源为用户提供服务。

    根据shell调用的方式主要分为三种:

    1) 交互式注册shell

    2) 交互式非注册shell

    3) 非交互式shell

    Shell调用方式不同,则其初始化的过程也不同。

    1、交互式注册shell

    在“login:”提示下输入用户名与密码,并成功登陆后,linux系统会调用交互式shell。交互式注册shell利用etc/profile/etc/bash.bashrc文件,以及用户目录中的~/.bashrc等初始化文件(启动文件),设置用户的运行环境。

    2、交互式非注册shell

    shell命令提示符下输入shbash命令,将会进入非注册(也可看做当前shell的子shell)。此时,shell将会读取并执行etc/profile/etc/bash.bashrc等初始化文件,同时还会继承注册shell利用初始化文件设置的各种环境。

    3、非交互式shell

    非交互式shell主要用于运行shell脚本。当利用命令行界面提交一个shell,并等待shell执行完毕,整个运行环境即为非交互式shell

    1.2 “#!”是什么?

    通常,shell脚本的第一行均包含一个以“#!”为起始的文本行,表明当前文件是一个可以执行的shell脚本文件。紧随“#!”标志是一个路径文件名,指向用于执行当前shell脚本的命令解释程序。

    #bin/bash”表示调用linux系统默认的shell,即bash

    #bin/sh”表示调用linux系统sh解释该脚本。

    #bin/more”表示调用linux系统more解释该脚本。

    Eg1hello.sh

    1   #!/bin/bash

    2   # hello world demo.

    3   echo "hello world!!"  

    结果:


    第 行以“#”开头的表示注释,第 行从“#”开始至行结束为注释。

    Eg2readme.sh

    1   #!/bin/more

    2   # display myself

    3   This is a script to dispaly this file self 

    结果:



  • 相关阅读:
    LeetCode 109 Convert Sorted List to Binary Search Tree
    LeetCode 108 Convert Sorted Array to Binary Search Tree
    LeetCode 107. Binary Tree Level Order Traversal II
    LeetCode 106. Construct Binary Tree from Inorder and Postorder Traversal
    LeetCode 105. Construct Binary Tree from Preorder and Inorder Traversal
    LeetCode 103 Binary Tree Zigzag Level Order Traversal
    LeetCode 102. Binary Tree Level Order Traversal
    LeetCode 104. Maximum Depth of Binary Tree
    接口和多态性
    C# 编码规范
  • 原文地址:https://www.cnblogs.com/yangsanchao/p/5014487.html
Copyright © 2011-2022 走看看