{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/shell-advanced-techniques/",
  "atlas": "https://www.pystone.net/?node=shell-advanced-techniques#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/shell-advanced-techniques.md",
  "context": "https://www.pystone.net/notes/shell-advanced-techniques.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:shell-advanced-techniques",
  "slug": "shell-advanced-techniques",
  "title": "【batshell】Shell进阶",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "【batshell】Shell进阶",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "9ee6adb07fff5f09a7c6c786ed24507e088e4bbb8f89db4e9bd36ad7872d88af",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "【batshell】Shell进阶",
      "anchor": "batshellshell进阶",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#batshellshell%E8%BF%9B%E9%98%B6"
    },
    {
      "depth": 2,
      "text": "permission",
      "anchor": "permission",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#permission"
    },
    {
      "depth": 3,
      "text": "chmod",
      "anchor": "chmod",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#chmod"
    },
    {
      "depth": 2,
      "text": "text processing",
      "anchor": "text-processing",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#text-processing"
    },
    {
      "depth": 3,
      "text": "grep",
      "anchor": "grep",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#grep"
    },
    {
      "depth": 3,
      "text": "awk",
      "anchor": "awk",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#awk"
    },
    {
      "depth": 3,
      "text": "sed",
      "anchor": "sed",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#sed"
    },
    {
      "depth": 4,
      "text": "Substitution command",
      "anchor": "substitution-command",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#substitution-command"
    },
    {
      "depth": 3,
      "text": "xargs",
      "anchor": "xargs",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#xargs"
    },
    {
      "depth": 2,
      "text": "输出重定向",
      "anchor": "输出重定向",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#%E8%BE%93%E5%87%BA%E9%87%8D%E5%AE%9A%E5%90%91"
    },
    {
      "depth": 2,
      "text": "test命令",
      "anchor": "test命令",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#test%E5%91%BD%E4%BB%A4"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#ref"
    },
    {
      "depth": 2,
      "text": "进程查找与杀死",
      "anchor": "进程查找与杀死",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#%E8%BF%9B%E7%A8%8B%E6%9F%A5%E6%89%BE%E4%B8%8E%E6%9D%80%E6%AD%BB"
    },
    {
      "depth": 3,
      "text": "tasklist",
      "anchor": "tasklist",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#tasklist"
    },
    {
      "depth": 3,
      "text": "taskkill",
      "anchor": "taskkill",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#taskkill"
    },
    {
      "depth": 3,
      "text": "完整代码",
      "anchor": "完整代码",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81"
    },
    {
      "depth": 2,
      "text": "相关知识点",
      "anchor": "相关知识点",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#%E7%9B%B8%E5%85%B3%E7%9F%A5%E8%AF%86%E7%82%B9"
    },
    {
      "depth": 2,
      "text": "查询程序及命令行参数",
      "anchor": "查询程序及命令行参数",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#%E6%9F%A5%E8%AF%A2%E7%A8%8B%E5%BA%8F%E5%8F%8A%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref-1",
      "citation": "https://www.pystone.net/notes/shell-advanced-techniques/#ref-1"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:software-engineering-and-quality",
      "title": "软件工程与质量保障",
      "url": "https://www.pystone.net/notes/software-engineering-and-quality/",
      "atlas": "https://www.pystone.net/?node=software-engineering-and-quality#knowledge-atlas",
      "label": "软件工程与质量保障",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "CI-CD与质量保障/CI-CD工具链中的“【batshell】Shell进阶”导航项",
      "citation": "https://www.pystone.net/notes/software-engineering-and-quality/#ci-cd%E4%B8%8E%E8%B4%A8%E9%87%8F%E4%BF%9D%E9%9A%9Cci-cd%E5%B7%A5%E5%85%B7%E9%93%BE"
    }
  ],
  "contentMarkdown": "# 【batshell】Shell进阶\n\n> 创建时间：2021/7/21 15:42\n\n* permission\n    * chmod\n  * text processing\n    * grep\n    * awk\n    * sed\n      * Substitution command\n    * xargs\n  * 输出重定向\n  * test命令\n  * Ref\n\n## permission\n\n### chmod\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\nmake it executable\n\nPermission:\n\n  * read (r) = 4\n  * write (w) = 2\n  * execute (x) = 1\n\nEach permission may be on or off for each of three categories of users: the file or directory **owner** ; other people in the same **group** as the owner; and all **others**.\n\n  * u stands for user.\n  * g stands for group.\n  * o stands for others.\n  * a stands for all.\n\n`chmod u+x filename` \\- grant the execution permission to the owner of the file\n`chmod +x filename` = `chmod a+x filename`\n\n`chmod 777` = `chmod a=rwx`\n\n## text processing\n\n### grep\n\ngrep is a command-line utility for searching plain-text data sets for lines that match a **regular expression**.\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\nThe caret ^ and the dollar sign $ are meta-characters that respectively match the empty string at the beginning and end of a line.\n\n### awk\n\nhttps://en.wikipedia.org/wiki/AWK\nAWK (awk) is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool.\n\n### sed\n\nhttps://www.geeksforgeeks.org/sed-command-in-linux-unix-with-examples/\nhttps://en.wikipedia.org/wiki/Sed\n\nsed (\"stream editor\") is a Unix utility that parses and transforms text, using a simple, compact programming language.\n\n#### Substitution command\n\nsed OPTIONS... [SCRIPT] [INPUTFILE...]\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n### xargs\n\nhttps://en.wikipedia.org/wiki/Xargs\n\nxargs (short for \"eXtended ARGuments\" ) is a command on Unix and most Unix-like operating systems used to build and execute commands from standard input.\n\nSome commands such as grep and awk can take input either as command-line arguments or from the standard input. However, others such as cp and echo can only take input as arguments, which is why xargs is necessary.\n\n## 输出重定向\n\n0：标准输入；1：标准输出；2：标准错误\n\n2>&1表明将文件描述2（标准错误输出）的内容重定向到文件描述符1（标准输出），为什么1前面需要&？当没有&时，1会被认为是一个普通的文件，有&表示重定向的目标不是一个文件，而是一个文件描述符。\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\nhttp://xstarcd.github.io/wiki/shell/exec_redirect.html\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n## test命令\n\nhttps://www.runoob.com/linux/linux-shell-test.html\n\n## Ref\n\nhttps://zhuanlan.zhihu.com/p/47765176\nhttps://en.wikipedia.org/wiki/AWK\n\n\n> 创建时间：2021/9/24 18:20\n\n* 进程查找与杀死\n    * tasklist\n    * taskkill\n    * 完整代码\n  * 相关知识点\n  * 查询程序及命令行参数\n  * Ref\n\n## 进程查找与杀死\n\n### tasklist\n\n  * **Image name** is the name of the executable, e.g. explorer.exe or myapp.exe\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n### taskkill\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n### 完整代码\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n## 相关知识点\n\n1>nul 意思是不显示命令运行的正确提示\n2>nul 是不显示错误提示\n一起就是 正确错误的都不显示\n\n> 是重定向符号\n>  nul是空设备的意思\n>  把提示输入到空设备就不显示了\n\n## 查询程序及命令行参数\n\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n```csharp\nstring a = &quot;test&quot;;\nstring tmp = &quot;est&quot;;\nstring b = &quot;t&quot; + tmp;\nConsole.WriteLine(string .ReferenceEquals(str1, str2));\n\n```\n\n## Ref\n\nhttps://blog.csdn.net/c1520006273/article/details/50539092\n"
}
