返回「计算机、信息技术与工程」

【batshell】Shell进阶

更多
Markdown 结构化数据
本文目录 18 个章节

【batshell】Shell进阶

创建时间:2021/7/21 15:42

  • permission
    • chmod
    • text processing
      • grep
      • awk
      • sed
        • Substitution command
      • xargs
    • 输出重定向
    • test命令
    • Ref

permission

chmod

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

make it executable

Permission:

  • read (r) = 4
  • write (w) = 2
  • execute (x) = 1

Each 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.

  • u stands for user.
  • g stands for group.
  • o stands for others.
  • a stands for all.

chmod u+x filename - grant the execution permission to the owner of the file chmod +x filename = chmod a+x filename

chmod 777 = chmod a=rwx

text processing

grep

grep is a command-line utility for searching plain-text data sets for lines that match a regular expression.

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

The caret ^ and the dollar sign $ are meta-characters that respectively match the empty string at the beginning and end of a line.

awk

https://en.wikipedia.org/wiki/AWK AWK (awk) is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool.

sed

https://www.geeksforgeeks.org/sed-command-in-linux-unix-with-examples/ https://en.wikipedia.org/wiki/Sed

sed ("stream editor") is a Unix utility that parses and transforms text, using a simple, compact programming language.

Substitution command

sed OPTIONS... [SCRIPT] [INPUTFILE...]

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

xargs

https://en.wikipedia.org/wiki/Xargs

xargs (short for "eXtended ARGuments" ) is a command on Unix and most Unix-like operating systems used to build and execute commands from standard input.

Some 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.

输出重定向

0:标准输入;1:标准输出;2:标准错误

2>&1表明将文件描述2(标准错误输出)的内容重定向到文件描述符1(标准输出),为什么1前面需要&?当没有&时,1会被认为是一个普通的文件,有&表示重定向的目标不是一个文件,而是一个文件描述符。

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

http://xstarcd.github.io/wiki/shell/exec_redirect.html

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

test命令

https://www.runoob.com/linux/linux-shell-test.html

Ref

https://zhuanlan.zhihu.com/p/47765176 https://en.wikipedia.org/wiki/AWK

创建时间:2021/9/24 18:20

  • 进程查找与杀死
    • tasklist
    • taskkill
    • 完整代码
    • 相关知识点
    • 查询程序及命令行参数
    • Ref

进程查找与杀死

tasklist

  • Image name is the name of the executable, e.g. explorer.exe or myapp.exe
string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));
string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));
string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

taskkill

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));
string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

完整代码

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

相关知识点

1>nul 意思是不显示命令运行的正确提示 2>nul 是不显示错误提示 一起就是 正确错误的都不显示

是重定向符号 nul是空设备的意思 把提示输入到空设备就不显示了

查询程序及命令行参数

string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));
string a = "test";
string tmp = "est";
string b = "t" + tmp;
Console.WriteLine(string .ReferenceEquals(str1, str2));

Ref

https://blog.csdn.net/c1520006273/article/details/50539092