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

    1、sh -x 跟踪shell脚本中的每个命令

    [root@master shellexer]# cat bash.sh
    #!/bin/bash
    var=$1
    echo $var
    [root@master shellexer]# sh -x bash.sh hello
    + var=hello
    + echo hello
    hello         #脚本输出结果
     #带+的表示被跟踪的代码

    https://blog.csdn.net/qq_15547319/article/details/70538091

    2、basename 从完整/不完整的路径名中获取文件名

    https://blog.csdn.net/flyfrommath/article/details/61933861

    3、hadoop——streaming job failed错误,streaming命令出错,看一下streaming命令中定义的那些文件夹是否都存在,可能是缺某个文件夹

    4、shell中[-eq] [-ne] [-gt] [-lt] [ge] [le]命令

    -eq           //等于

    -ne           //不等于

    -gt            //大于 (greater )

    -lt            //小于  (less)

    -ge            //大于等于

    -le            //小于等于

    命令的逻辑关系:

    在linux 中 命令执行状态:0 为真,其他为假

    逻辑与: &&
    第一个条件为假时,第二条件不用再判断,最终结果已经有;
    第一个条件为真时,第二条件必须得判断;
    逻辑或: ||
    逻辑非: !

    https://www.cnblogs.com/jxhd1/p/6274854.html

    5、$XXXX的意思

    $0 这个程式的执行名字
    $n 这个程式的第n个参数值,n=1..9
    $* 这个程式的所有参数,此选项参数可超过9个。
    $# 这个程式的参数个数
    $$ 这个程式的PID(脚本运行的当前进程ID号)
    $! 执行上一个背景指令的PID(后台运行的最后一个进程的进程ID号)
    $? 执行上一个指令的返回值 (显示最后命令的退出状态。0表示没有错误,其他任何值表明有错误)
    $- 显示shell使用的当前选项,与set命令功能相同
    $@ 跟$*类似,但是可以当作数组用

    https://zhidao.baidu.com/question/262951766.html

    6、-d命令

    判断表达式:[ -d temp ]

    判断temp是否为文件夹

    https://zhidao.baidu.com/question/321750604.html

    7、判断表达式

     if [ 3 -eq 3 ] ; then echo hello ; fi

    https://zhidao.baidu.com/question/322131711.html

    https://blog.csdn.net/zgf19930504/article/details/51911732

    8、if  then  elif  else  fi条件语句

    https://www.cnblogs.com/linux-super-meng/p/3763255.html

    https://blog.csdn.net/ljchlx/article/details/18263397

    9、hadoop shell命令

    -copyfromlocal 上传文件

    -rmr 删除文件

    stream 指定参数

    http://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html

    http://dongxicheng.org/mapreduce/hadoop-streaming-programming/

    9、awk命令

    http://www.runoob.com/linux/linux-comm-awk.html

    10、sed命令

    http://www.runoob.com/linux/linux-comm-sed.html

    11、sed+shell正则

    http://wiki.jikexueyuan.com/project/unix/regular-expressions.html

    12、解决swap file already exists问题

    ls -a查看一下,将同一目录下隐藏的 *.swp 文件删除即可

  • 相关阅读:
    Centos 安装TensorFlow
    Centos 编译TensorFlow C/C++库 libtensorflow.so libtensorflow_framework.so
    机器学习常用库速查表 文献收藏
    Jupyter 取消括号自动匹配
    Sklearn 错误 No module named 'cross_validation' 错误 No module named 'mode_selection'
    Centos 设置iptables端口转发 “Unit iptables.service could not be found”错误
    三角函数tan、arctan与双曲函数tanh 学习笔记
    Moco框架
    fake_useragent
    chardet
  • 原文地址:https://www.cnblogs.com/zealousness/p/9410496.html
Copyright © 2011-2022 走看看