• 变量及变量类型


    编译器,解释器

    编程语言:机器语言、汇编语言、高级语言

    静态语言:编译型语言

      强类型(变量类型):变量在使用前,必须事先声明,初始化

      关键字

      事先转换成可执行格式

      C,C++,Java,C#,

    动态语言:解释型语言, on the fly

      弱类型:变量用时声明,不区分类型(Python)

      边解释边执行

      PHP,shell,python,perl

    面向过程:shell,C

    面向对象:Java,Python,Perl,C++

    变量:内存空间,命名

    变量类型:事先确定数据的存储格式和长度

      字符

      数值

        整型

        浮点型

      日期时间型

      布尔类型

    变量赋值:a=b

    内存:编址的存储单元

    bash变量类型:

      环境变量:PATH

      本地变量(局部变量)

      位置变量

      特殊变量

    本地变量:

      NAME=Jerry,作用域为整个bash进程;

    局部变量:

      local NAME=Jerry,作用域为当前代码段

    环境变量:作用域为,当前shell进程及其子进程;

    export NAME=Jerry

      “导出”

    位置变量:

    $1,$2,

    特殊变量:

    $?:上一个命令的执行状态返回值

      

      程序执行,可能有两类返回值:

      程序执行结果

      程序状态返回代码(0~255)

      echo $?

        0:正确执行

        1~255:错误执行,1,2,127系统预留;

    输出重定向:

    >

    >>

    2>

    2>>

    &>

    /dev/null:软件设备,bit bucket,位桶,数据黑洞

      id student &> /dev/null,输出至空

    撤销变量:

    unset NAME

    查看当前shell中变量:

      set

    查看当前shell中的环境变量:

    printenv

    env

    export

    脚本在执行时,会启动一个子shell进程

      命令行中启动的脚本会继承当前shell环境变量;

      系统自动执行的脚本(非命令行启动)就需要自我定义需要各环境变量;

    引用变量:${NAME},括号可省略

    脚本:

    shebang:魔数

    # 注释行,不执行

    vim practice.sh

    #!/bin/bash

      cat /etc/inittab

      ls /var

    脚本加执行权限

    chmod+x  practice.sh

    当前路径执行

    ./practice.sh  

    sh practice.sh

    Linux可执行文件格式:

    ELF:Executable and Linkable Format,可执行与可链接格式

  • 相关阅读:
    安全编码1
    VPP tips
    VPP概述汇总
    C语言安全编码摘录
    TCP-proxy
    Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.4. Matplotlib: plotting
    Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.3. NumPy: creating and manipulating numerical data
    Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.2. The Python language
    Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.1. Python scientific computing ecosystem
    25马5跑道,求最快的五匹马的需要比赛的次数
  • 原文地址:https://www.cnblogs.com/isunny/p/5883640.html
Copyright © 2020-2023  润新知