zoukankan      html  css  js  c++  java
  • shell语法 01-shell基础概述

    • shell是一个命令解释器
    • shell脚本类似于DOS系统(磁盘操作系统)下的批处理程序
    • shell脚本语言很适合用于处理纯文本类型的数据(配置文件、日志文件)
    • shell脚本语言是弱类型语言(无须定义变量的类型即可使用)

    shell的类型

    [root@centos6 ~]# cat /etc/shells
    /bin/sh		    # 指向/bin/bash,sh为bash的软连接
    /bin/bash	    # 默认的使用的shell
    /sbin/nologin	# 用于禁止用户登录
    /bin/dash
    /bin/tcsh
    /bin/csh
    

    脚本执行的方式:

    bash test.sh	# 无需修改权限
    sh test.sh		# 无需修改权限
    ./test.sh		# 需要修改执行权限chmod +x test.sh
    source test.sh	# 相当于PHP的include
    sh<test.sh
    cat test.sh|sh
    

    command >/dev/null 2>&1 &
    
    • /dev/null 表示空设备文件
      • 0 表示stdin标准输入(一般是键盘)
      • 1 表示stdout标准输出(一般是显示屏,准确的说是用户终端控制台)
      • 2 表示stderr标准错误(出错信息输出)
    • >/dev/null:重定向到/dev/null的设备文件中
    • 2>&1:用来将标准错误2重定向到标准输出1中的,1前面的&就是为了让bash将1解释成标准输出而不是文件1
    • 最后一个&:是让bash在后台执行。
  • 相关阅读:
    redis集群规范
    mongodb的基本使用
    redis进阶
    redis基本使用
    selenium的基本使用
    C++入门
    C语言入门
    MATLAB中矩阵reshape的顺序规律
    Tensorflow:ImportError: DLL load failed: 找不到指定的模块 Failed to load the native TensorFlow runtime
    差分定位和精密定位
  • 原文地址:https://www.cnblogs.com/liangjingfu/p/9419060.html
Copyright © 2011-2022 走看看