zoukankan      html  css  js  c++  java
  • shell学习

     
    • readlink是linux系统中一个常用工具,主要用来找出符号链接所指向的位置。
    • 定义变量“=”两边不能有空格,否则会被shell解析错误。
    • tee 同时将输出内容显示在屏幕上、记录在文件里
    • 三种引号‘’,“”,``。
      •   rm -rf ‘my document’  ----当命令行里面包含空格时,用单引号包含起来
      • 这时也可由用双引号,区别在于双引号的值会被变量的之替换,单引号保持原样。
      •  
        $ ABC=hello
        $ echo 'string is ${ABC}'
        string is ${ABC}
        $ echo "string is ${ABC}"
        string is hello

        反引号实际上就是命令替换

      • echo `uname`  #等价 echo $(uname)
      • $ echo `uname -a`
        Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
        $ uname -a
        Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
    •  脚本的执行
      •  
        $ vi test.sh 
        $ cat test.sh 
        echo " this is a test"
        
        $ ls -al
        total 12
        drwxr-xr-x  2 xwei xwei 4096 Mar 10 16:49 .
        drwxr-xr-x 16 xwei xwei 4096 Mar 10 15:28 ..
        -rw-rw-r--  1 xwei xwei   26 Mar 10 16:49 test.sh
        $ . test.sh  #以source test.sh 方式执行,读入文件中的命令,在当前shell执行,source内置命令,无需执行权限,其可以缩写为一个小数点
         this is a test
        $ ./test.sh  # 
        bash: ./test.sh: Permission denied
        
        xwei@ubuntu:~/Desktop$ chmod a+x test.sh 
        xwei@ubuntu:~/Desktop$ ls -al
        total 12
        drwxr-xr-x  2 xwei xwei 4096 Mar 10 16:49 .
        drwxr-xr-x 16 xwei xwei 4096 Mar 10 15:28 ..
        -rwxrwxr-x  1 xwei xwei   26 Mar 10 16:49 test.sh
        $ ./test.sh  #在一个子shell中执行命令
         this is a test
    该博客停止更新,继续关注请移步: www.foolweel.com
  • 相关阅读:
    逐点分析,这样做Web端性能测试
    如何完成大数据测试-从功能测试角度分析
    自动化测试和手动测试利弊
    (一)SQL注入漏洞测试的方式总结
    如何设计一个完整的测试用例
    测试与开发、产品、上下级沟通、
    黑盒测试用例设计总结
    改变测试思路,你的性能测试才能更值钱!(下)
    20190923-03Linux时间日期类 000 011
    20190923-02Linux文件目录类 000 010
  • 原文地址:https://www.cnblogs.com/Qwells/p/5262386.html
Copyright © 2011-2022 走看看