zoukankan      html  css  js  c++  java
  • Linux命令行和Shell脚本编程

    1. variable

    2. control flow

    3. commands

    3.1 how to set your own prompt

      echo $PS1  -- the default format of your command line prompt

      echo $PS2  -- the format of the second-tier command line prompt

      update:

      PS1="[\t]\$"  it will show like this:[21:51:22]$

      (this only apply to the current session)

    3.2 using the bash manual

      man grep

    3.3 Make sure the linux uses a virtural directory.(This is not the method used by windows)

      it uses a single directory called "root"

      You will notice that linux uses a forward slash(/) instead of a backward slash(\) to denote directories in filepaths.

      The backward slash denote a escape character.

    3.4 traverse directories

      cd command

      ----------common linux directories name

      /bin    the binary directory, where many usr-level utilities are stored

      /etc    the system confiruration file directory

      /home    the home directory, where linux creates user directories

      /opt    often used to store optional software packages

      /sbin    the binary directory, where many admin-level utilities are stored

      /usr    the user-installed software directory

      /var    the variable directory, for files that change frequently, such as log file.

    3.5 the filter of ls command

      ls -l *XXX*   can choose the file/directory including XXX

    3.6 create file

      touch

    3.7 copy files

      cp test1 destination

      (if the destination file exists, the cp command will prompt you to answer whethre or not you want to overwrite it.)

    3.8 rename file

      in linux world, renaming file means moving, use mv command:

      mv test.txt test1.txt

      ls -l test*

      -rwxrwxrwx 1 Administrator None 9 2010-05-29 01:02 test1.txt

      (Notice that moving the file changes the file name but keep the same inode number and timestamp value.)

    3.9 delete files

      in linux world, delete files means removing, use rm command:

      rm -i test.txt

      (Notice that the command prompts you make sure you are serious to delete the file.)

    3.10 create/delete directories

      mkdir/rmdir command

    3.11 view file statistic

      stat test.txt

       File: `test.txt'
      Size: 13              Blocks: 1          IO Block: 65536  regular file
      Device: 601c6e4dh/1612475981d   Inode: 562949953465703  Links: 1
      Access: (0644/-rw-r--r--)  Uid: (  500/Administrator)   Gid: (  513/    None)
      Access: 2010-05-29 22:48:27.468750000 +0800
      Modify: 2010-05-29 22:52:11.015625000 +0800
      Change: 2010-05-29 22:52:11.015625000 +0800

    3.12 view whole file

      cat/more/less/

    3.13 view part of the file

      tail/head

  • 相关阅读:
    EdgeDB 1.0 Alpha 4 发布了
    静态文件请求路径 rewrite nginx && openresty 实现
    Giving Application Pools Event Log Access
    一张图看懂ASP.NET MVC5认证和授权过滤器的执行顺序
    git check-ignore
    What does “Challenge” term stand for?
    Implementing MVC 5 IAuthenticationFilter
    HttpContext.Current.User is null even though Windows Authentication is on
    When should the volatile keyword be used in C#?
    HttpApplicationState.Remove(String) Method
  • 原文地址:https://www.cnblogs.com/kelin1314/p/1746715.html
Copyright © 2011-2022 走看看