Bash命令基础

Bash is a utility to manage Linux and UNIX boxes and it is very popular because of its simple, well documented and unique usage. There are alternatives to bash like csh,sh,ksh but bash has very high usage rate against others. I have recently work on bash with its manual and wanted to write something that I have learned from them. By the way, bash is an acronym for “Bourne again shell”.

Bash是一种用于管理Linux和UNIX机器的实用程序,由于其简单,详细记录且独特的用法而非常受欢迎。 bash有其他替代方法,例如csh,sh,ksh,但bash与其他工具相比具有很高的使用率。 我最近在bash上使用了它的手册,并想写一些我从bash中学到的东西。 顺便说一句,bash是“ Bourne Again Shell”的首字母缩写。

Bash reads input and goes on a sequential manner. is treated as comment line like this.

Bash读取输入并按顺序进行。 像这样被当作注释行。

#Below is ping function to ismailbaydan.com ping ismailbaydan.com  # Ping the host

Here is what really bash make.

这才是真正的bash。

  1. Reads script from various sources like terminal, file, etc.

    从终端,文件等各种来源读取脚本。
  2. Than parses the string in the input and makes required expansions and then gets commands.

    比解析输入中的字符串并进行必要的扩展,然后获取命令。
  3. Performs necessary directions

    执行必要的指示
  4. Executes commands and wait for the completion of the commands for their status.

    执行命令并等待命令完成以获取其状态。

As you can see there is a lot of work to execute a command or script in bash. But all of them makes the commands run in a perfect manner.

如您所见,在bash中执行命令或脚本有很多工作。 但是所有这些都使命令以完美的方式运行。

报价单 (Quoting)

Quoting is clearing special words and strings from the script and make them work correctly. A non-quoted backslash escapes character for the bash. Using single quote preserves characters in the string even usage of backslash but with double quoting makes $  ‘  \ special. For example, \t is a tab.

引用是从脚本中清除特殊的单词和字符串,并使它们正常工作。 bash的不带引号的反斜杠转义字符。 使用单引号即使使用反斜杠也可以保留字符串中的字符,但是使用双引号会使$'\特别。 例如,\ t是一个选项卡。

"İsmail Baydan\' website is \t ismailbaydan.com"

简单命令 (Simple Commands)

Generally, the line starts with commands and their arguments in bash and separated with blanks like this. Here ls is the command and /home/ismailbaydan is the argument. There may be a lot of arguments.

通常,该行以bash中的命令及其参数开头,并以空格分隔。 这里的ls是命令,而/home/ismailbaydan是参数。 可能有很多争论。

$ ls /home/ismailbaydan

流水线 (Pipelining)

The pipe is used to connect commands together. For example, to echo the content of the text file and look for a string is like this. grep uses the output of the cat command.

管道用于将命令连接在一起。 例如,回显文本文件的内容并查找字符串是这样的。 grep使用cat命令的输出。

$ cat phone_numbers.txt | grep Baydan İsmail Baydan 123456

定时 (Timing)

Timing is used to count CPU usage or time for a command. Here we make some copying and count for CPU usage.

计时用于计算命令的CPU使用率或时间。 在这里,我们进行一些复制并计算CPU使用率。

$ time dd count=100000 if=/dev/urandom of=/dev/null
LEARN MORE  How To Redirect Stderr To Stdout In Linux Bash?
了解更多如何在Linux Bash中将Stderr重定向到Stdout?

Bash命令基础知识图 (Bash Command Basics Infographic)

Bash Command Basics Infographic
Bash Command Basics Infographic
Bash命令基础知识图

翻译自: https://www.poftut.com/bash-command-basics/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值