• 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
  • 相关阅读:
    将asp页面转换成htm页面的方法
    JavaScript 参考教程
    ASP六大对象介绍
    Asp组件初级入门与精通系列之二
    Asp组件初级入门与精通系列之三
    asp中防止脚本注入攻击
    Asp组件初级入门与精通系列之六
    取得select的option的text值
    用組件封裝數據庫操作(二)
    SQL注入天书ASP注入漏洞全接触
  • 原文地址:https://www.cnblogs.com/Qwells/p/5262386.html
Copyright © 2020-2023  润新知