Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-01-22 10:30:10 +08:00
commit 05a6f377dc
5 changed files with 302 additions and 313 deletions

View File

@ -0,0 +1,185 @@
[#]: collector: (lujun9972)
[#]: translator: (asche910)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10465-1.html)
[#]: subject: (Linux Tools: The Meaning of Dot)
[#]: via: (https://www.linux.com/blog/learn/2019/1/linux-tools-meaning-dot)
[#]: author: (Paul Brown https://www.linux.com/users/bro66)
Linux 工具:点的含义
======
> Paul Brown 解释了 Linux shell 命令中那个不起眼的“点”的各种意思和用法。
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/psychedelic-dot.jpg?itok=giKEHvwQ)
在现实情况中,使用 shell 命令编写的单行命令或脚本可能会令人很困惑。你使用的很多工具的名称与它们的实际功能相差甚远(`grep`、`tee` 和 `awk`,还有吗?),而当你将两个或更多个组合起来时,所组成的 “句子” 看起来更像某种外星人的天书。
因此,上面说的这些对于你并无帮助,因为你用来编写一连串的指令所使用的符号根据你使用的场景有着不同的意义。
### 位置、位置、位置
就拿这个不起眼的点(`.`)来说吧。当它放在一个需要一个目录名称的命令的参数处时,表示“当前目录”:
```
find . -name "*.jpg"
```
意思就是“在当前目录(包括子目录)中寻找以 `.jpg` 结尾的文件”。
`ls .``cd .` 结果也如你想的那样,它们分别列举和“进入”到当前目录,虽然在这两种情况下这个点都是多余的。
而一个紧接着另一个的两个点呢,在同样的场景下(即当你的命令期望一个文件目录的时候)表示“当前目录的父目录”。如果你当前在 `/home/your_directory` 下并且运行:
```
cd ..
```
你就会进入到 `/home`。所以,你可能认为这仍然适合“点代表附近目录”的叙述,并且毫不复杂,对吧?
那下面这样会怎样呢?如果你在一个文件或目录的开头加上点,它表示这个文件或目录会被隐藏:
```
$ touch somedir/file01.txt somedir/file02.txt somedir/.secretfile.txt
$ ls -l somedir/
total 0
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file01.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file02.txt
$ # 注意上面列举的文件中没有 .secretfile.txt
$ ls -la somedir/
total 8
drwxr-xr-x 2 paul paul 4096 Jan 13 19:57 .
drwx------ 48 paul paul 4096 Jan 13 19:57 ..
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file01.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file02.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 .secretfile.txt
$ # 这个 -a 选项告诉 ls 去展示“all”文件包括那些隐藏的
```
然后就是你可以将 `.` 当作命令。是的,你听我说:`.` 是个真真正正的命令。它是 `source` 命令的代名词,所以你可以用它在当前 shell 中执行一个文件,而不是以某种其它的方式去运行一个脚本文件(这通常指的是 Bash 会产生一个新的 shell 去运行它)
很困惑?别担心 —— 试试这个:创建一个名为 `myscript` 的脚本,内容包含下面一行:
```
myvar="Hello"
```
然后通过常规的方法执行它,也就是用 `sh myscript`(或者通过 `chmod a+x myscript` 命令让它可执行,然后运行 `./myscript`)。现在尝试并且观察 `myvar` 的内容,通过 `echo $myvar`(理所当然你什么也得不到)。那是因为,当你的脚本赋值 `"Hello"``myvar`它是在一个隔离的bash shell 实例中进行的。当脚本运行结束时这个新产生的实例会消失并且将控制权转交给原来的shell而原来的 shell 里甚至都不存在 `myvar` 变量。
然而,如果你这样运行 `myscript`
```
. myscript
```
`echo $myvar` 就会打印 `Hello` 到命令行上。
当你的 `.bashrc` 文件发生变化后,你经常会用到 `.`(或 `source`)命令,[就像当你要扩展 `PATH` 变量那样][1]。在你的当前 shell 实例中,你可以使用 `.` 来让变化立即生效。
### 双重麻烦
就像看似无关紧要的一个点有多个含义一样,两个点也是如此。除了指向当前目录的父级之外,两个点(`..`)也用于构建序列。
尝试下这个:
```
echo {1..10}
```
它会打印出从 1 到 10 的序列。在这种场景下,`..` 表示 “从左边的值开始,计数到右边的值”。
现在试下这个:
```
echo {1..10..2}
```
你会得到 `1 3 5 7 9`。`..2` 这部分命令告诉 Bash 输出这个序列,不过不是每个相差 1而是相差 2。换句话说就是你会得到从 1 到 10 之间的奇数。
它反着也仍然有效:
```
echo {10..1..2}
```
你也可以用多个 0 填充你的数字。这样:
```
echo {000..121..2}
```
会这样打印出从 0 到 121 之间的偶数(填充了前置 0
```
000 002 004 006 ... 050 052 054 ... 116 118 120
```
不过这样的序列发生器有啥用呢?当然,假设您的新年决心之一是更加谨慎控制您的帐户花销。作为决心的一部分,您需要创建目录,以便对过去 10 年的数字发票进行分类:
```
mkdir {2009..2019}_Invoices
```
工作完成。
或者你可能有数百个带编号的文件,比如从视频剪辑中提取的帧,或许因为某种原因,你只想从第 43 帧到第 61 帧每隔三帧删除一帧:
```
rm frame_{043..61..3}
```
很可能,如果你有超过 100 个帧,它们将以填充 0 命名,如下所示:
```
frame_000 frame_001 frame_002 ...
```
那就是为什么你在命令中要用 `043`,而不是`43` 的原因。
### 花括号花招
说实话,序列的神奇之处不在于双点,而是花括号(`{}`)的巫术。看看它对于字母是如何工作的。这样做:
```
touch file_{a..z}.txt
```
它创建了从 `file_a.txt``file_z.txt` 的文件。
但是,你必须小心。使用像 `{Z..a}` 这样的序列将产生一大堆大写字母和小写字母之间的非字母、数字的字符(既不是数字或字母的字形)。其中一些字形是不可打印的或具有自己的特殊含义。使用它们来生成文件名称可能会导致一系列意外和可能令人不快的影响。
最后一件值得指出的事:包围在 `{...}` 的序列,它们也可以包含字符串列表:
```
touch {blahg, splurg, mmmf}_file.txt
```
将创建了 `blahg_file.txt`、`splurg_file.txt` 和 `mmmf_file.txt`
当然,在别的场景中,大括号也有不同的含义(惊喜吗!)。不过那是别的文章的内容了。
### 总结
Bash 以及运行于其中的各种工具已经被寻求解决各种特定问题的系统管理员们把玩了数十年。要说这种有自己之道的系统管理员是一种特殊物种的话那是有点轻描淡写。总而言之与其他语言相反Bash 的设计目标并不是为了用户友好、简单、甚至合乎逻辑。
但这并不意味着它不强大 —— 恰恰相反。Bash 的语法和 shell 工具可能不一致且很庞大,但它们也提供了一系列令人眼花缭乱的方法来完成您可能想象到的一切。就像有一个工具箱,你可以从中找到从电钻到勺子的所有东西,以及橡皮鸭、一卷胶带和一些指甲钳。
除了引人入胜之外,探明你可以直接在 shell 中达成的所有能力也很有趣,所以下次我们将深入探讨如何构建更大更好的 Bash 命令行。
在那之前,玩得开心!
--------------------------------------------------------------------------------
via: https://www.linux.com/blog/learn/2019/1/linux-tools-meaning-dot
作者:[Paul Brown][a]
选题:[lujun9972][b]
译者:[asche910](https://github.com/asche910)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linux.com/users/bro66
[b]: https://github.com/lujun9972
[1]: https://www.linux.com/blog/learn/2018/12/bash-variables-environmental-and-otherwise

View File

@ -1,116 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Managing dotfiles with rcm)
[#]: via: (https://fedoramagazine.org/managing-dotfiles-rcm/)
[#]: author: (Link Dupont https://fedoramagazine.org/author/linkdupont/)
Managing dotfiles with rcm
======
![](https://fedoramagazine.org/wp-content/uploads/2018/12/dotfiles-816x345.jpg)
A hallmark feature of many GNU/Linux programs is the easy-to-edit configuration file. Nearly all common free software programs store configuration settings inside a plain text file, often in a structured format like JSON, YAML or [“INI-like”][1]. These configuration files are frequently found hidden inside a users home directory. However, a basic ls wont reveal them. UNIX standards require that any file or directory name that begins with a period (or “dot”) is considered “hidden” and will not be listed in directory listings unless requested by the user. For example, to list all files using the ls program, pass the -a command-line option.
Over time, these configuration files become highly customized, and managing them becomes increasingly more challenging as time goes on. Not only that, but keeping them synchronized between multiple computers is a common challenge in large organizations. Finally, many users find a sense of pride in their unique configuration settings and want an easy way to share them with friends. Thats where **rcm** steps in.
**rcm** is a “rc” file management suite (“rc” is another convention for naming configuration files that has been adopted by some GNU/Linux programs like screen or bash). **rcm** provides a suite of commands to manage and list files it tracks. Install **rcm** using **dnf**.
### Getting started
By default, **rcm** uses ~/.dotfiles for storing all the dotfiles it manages. A managed dotfile is actually stored inside ~/.dotfiles, and a symlink is placed in the expected files location. For example, if ~/.bashrc is tracked by **rcm** , a long listing would look like this.
```
[link@localhost ~]$ ls -l ~/.bashrc
lrwxrwxrwx. 1 link link 27 Dec 16 05:19 .bashrc -> /home/link/.dotfiles/bashrc
[link@localhost ~]$
```
**rcm** consists of 4 commands:
* mkrc convert a file into a dotfile managed by rcm
* lsrc list files managed by rcm
* rcup synchronize dotfiles managed by rcm
* rcdn remove all the symlinks managed by rcm
### Share bashrc across two computers
It is not uncommon today for a user to have shell accounts on more than one computer. Keeping dotfiles synchronized between those computers can be a challenge. This scenario will present one possible solution, using only **rcm** and **git**.
First, convert (or “bless”) a file into a dotfile managed by **rcm** with mkrc.
```
[link@localhost ~]$ mkrc -v ~/.bashrc
Moving...
'/home/link/.bashrc' -> '/home/link/.dotfiles/bashrc'
Linking...
'/home/link/.dotfiles/bashrc' -> '/home/link/.bashrc'
[link@localhost ~]$
```
Next, verify the listings are correct with lsrc.
```
[link@localhost ~]$ lsrc
/home/link/.bashrc:/home/link/.dotfiles/bashrc
[link@localhost ~]$
```
Now create a git repository inside ~/.dotfiles and set up an accessible remote repository using your choice of hosted git repositories. Commit the bashrc file and push a new branch.
```
[link@localhost ~]$ cd ~/.dotfiles
[link@localhost .dotfiles]$ git init
Initialized empty Git repository in /home/link/.dotfiles/.git/
[link@localhost .dotfiles]$ git remote add origin git@github.com:linkdupont/dotfiles.git
[link@localhost .dotfiles]$ git add bashrc
[link@localhost .dotfiles]$ git commit -m "initial commit"
[master (root-commit) b54406b] initial commit
1 file changed, 15 insertions(+)
create mode 100644 bashrc
[link@localhost .dotfiles]$ git push -u origin master
...
[link@localhost .dotfiles]$
```
On the second machine, clone this repository into ~/.dotfiles.
```
[link@remotehost ~]$ git clone git@github.com:linkdupont/dotfiles.git ~/.dotfiles
...
[link@remotehost ~]$
```
Now update the symlinks managed by **rcm** with rcup.
```
[link@remotehost ~]$ rcup -v
replacing identical but unlinked /home/link/.bashrc
removed '/home/link/.bashrc'
'/home/link/.dotfiles/bashrc' -> '/home/link/.bashrc'
[link@remotehost ~]$
```
Overwrite the existing ~/.bashrc (if it exists) and restart the shell.
Thats it! The host-specific option (-o) is a useful addition to the scenario above. And as always, be sure to read the manpages; they contain a wealth of example commands.
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/managing-dotfiles-rcm/
作者:[Link Dupont][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/linkdupont/
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/INI_file

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,116 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Managing dotfiles with rcm)
[#]: via: (https://fedoramagazine.org/managing-dotfiles-rcm/)
[#]: author: (Link Dupont https://fedoramagazine.org/author/linkdupont/)
用 rcm 管理隐藏文件
======
![](https://fedoramagazine.org/wp-content/uploads/2018/12/dotfiles-816x345.jpg)
许多 GNU/Linux 程序的一个特点是易于编辑的配置文件。几乎所有常见的自由软件都将配置设置保存在纯文本文件中,通常采用结构化格式,如 JSON、YAML或[“类 ini”][1]。这些配置文件经常隐藏在用户的主目录中。但是,基本的 ls 不会显示它们。UNIX 标准要求以点开头的任何文件或目录名称都被视为“隐藏”,除非用户请求,否则不会列在目录列表中。例如,要使用 ls 列出所有文件,要传递 -a 选项。
随着时间的推移,这些配置文件变得高度自定义,管理它们变得越来越具有挑战性。不仅如此,在多台计算机之间保持同步是大型组织的共同挑战。最后,许多用户对其独特的配置感到自豪,并希望以简单的方式与朋友分享。这就是用到 **rcm** 介入的地方。
**rcm** 是一个 “rc” 文件管理套件“rc” 是命名配置文件的另一种约定,它已被某些 GNU/Linux 程序采用,如 screen 或 bash**rcm** 提供了一套命令来管理和列出它跟踪的文件。使用 **dnf** 安装 **rcm**
### 开始使用
默认情况下,**rcm** 使用 ~/.dotfiles 保存它管理的所有隐藏文件。托管的隐藏文件实际保存在 ~/.dotfiles 中,并保存符号链接在文件原本的位置。例如,如果 ~/.bashrc 由 **rcm** 跟踪,那么详细列表将如下所示。
```
[link@localhost ~]$ ls -l ~/.bashrc
lrwxrwxrwx. 1 link link 27 Dec 16 05:19 .bashrc -> /home/link/.dotfiles/bashrc
[link@localhost ~]$
```
**rcm** 包含 4 个命令:
* mkrc 将文件转换为由 rcm 管理的隐藏文件
* lsrc 列出由 rcm 管理的文件
* rcup 同步由 rcm 管理的隐藏文件
* rcdn 删除 rcm 管理的所有符号链接
### 在两台计算机上共享 bashrc
如今用户在多台计算机上拥有 shell 帐户并不罕见。在这些计算机之间同步隐藏文件可能是一个挑战。这里将提供一种可能的解决方案,仅使用 **rcm****git**
首先使用 mkrc 将文件转换成由 **rcm** 管理的文件。
```
[link@localhost ~]$ mkrc -v ~/.bashrc
Moving...
'/home/link/.bashrc' -> '/home/link/.dotfiles/bashrc'
Linking...
'/home/link/.dotfiles/bashrc' -> '/home/link/.bashrc'
[link@localhost ~]$
```
接下来使用 lsrc 验证列表。
```
[link@localhost ~]$ lsrc
/home/link/.bashrc:/home/link/.dotfiles/bashrc
[link@localhost ~]$
```
现在在 ~/.dotfiles 中创建一个 git 仓库,并使用你选择的 git 仓库托管设置一个远程仓库。提交 bashrc 文件并推送一个新分支。
```
[link@localhost ~]$ cd ~/.dotfiles
[link@localhost .dotfiles]$ git init
Initialized empty Git repository in /home/link/.dotfiles/.git/
[link@localhost .dotfiles]$ git remote add origin git@github.com:linkdupont/dotfiles.git
[link@localhost .dotfiles]$ git add bashrc
[link@localhost .dotfiles]$ git commit -m "initial commit"
[master (root-commit) b54406b] initial commit
1 file changed, 15 insertions(+)
create mode 100644 bashrc
[link@localhost .dotfiles]$ git push -u origin master
...
[link@localhost .dotfiles]$
```
在第二台机器上,克隆这个仓库到 ~/.dotfiles 中。
```
[link@remotehost ~]$ git clone git@github.com:linkdupont/dotfiles.git ~/.dotfiles
...
[link@remotehost ~]$
```
现在使用 rcup 更新受 **rcm** 管理的符号链接。
```
[link@remotehost ~]$ rcup -v
replacing identical but unlinked /home/link/.bashrc
removed '/home/link/.bashrc'
'/home/link/.dotfiles/bashrc' -> '/home/link/.bashrc'
[link@remotehost ~]$
```
覆盖现有的 ~/.bashrc如果存在并重启 shell。
就是这些了!指定主机选项 -o 是对上面这种情况的有用补充。如往常一样,请阅读手册页。它们包含了很多示例命令。
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/managing-dotfiles-rcm/
作者:[Link Dupont][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/linkdupont/
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/INI_file

View File

@ -1,196 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (asche910)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Linux Tools: The Meaning of Dot)
[#]: via: (https://www.linux.com/blog/learn/2019/1/linux-tools-meaning-dot)
[#]: author: (Paul Brown https://www.linux.com/users/bro66)
Linux 工具: 点的含义
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/psychedelic-dot.jpg?itok=giKEHvwQ)
我们会面对这样的现实使用shell命令编写简短的脚本可能会令人很困惑。很多任你使用的工具的名称与它们的实际功能相差甚远(_grep_ , _tee__awk_ ,还有吗?) 并且当你将两个或更多个组合起来时,产生的“句子”看起来像某种外星人官样文章。
由于这样一个现实: 你用来编写一连串的指令所使用的符号标志根据你使用的场景有着不同的意义。所以它对我们上面的事并没有给予到帮助。
### 位置,位置,位置
就拿这个谦卑的点 (`.`) 为例。 它与接收一个目录名称的指令一起使用,表示“当前目录”:
```
find . -name "*.jpg"
```
意思就是“_在当前目录包括子目录中寻找以`.jpg`结尾的文件_”
`ls .` and `cd .`结果也同期望的那样,他们分别列举和“进入”到当前目录,虽然在这两种情况下点都是多余的。
两个点一个紧接着另一个同样的场景下即当你的命令期望一个文件目录的时候表示“_当前目录的父目录_”。如果你当前在 _/home/your_directory_ 下并且运行
```
cd ..
```
你就会进入到 _/home_。所以,你可能认为这仍然适合“点代表附近目录”的叙述,并且毫不复杂,对吧?
那这样会怎样呢?如果你在一个文件或目录的开头加上点,它表示这个文件或目录会被隐藏:
```
$ touch somedir/file01.txt somedir/file02.txt somedir/.secretfile.txt
$ ls -l somedir/
total 0
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file01.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file02.txt
$ # 注意上面列举的文件中没有 .secretfile.txt
$ ls -la somedir/
total 8
drwxr-xr-x 2 paul paul 4096 Jan 13 19:57 .
drwx------ 48 paul paul 4096 Jan 13 19:57 ..
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file01.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file02.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 .secretfile.txt
$ # 这个 -a 选项告诉 ls 去展示"all" 文件, 包括那些隐藏的
```
然后就是你将`.`当作命令。是的,你听我说过:`.`是个羽翼丰满的命令。它是`source` 的代名词 所以在当前shell中你可以用它来执行一个文件而不是以某些方法去运行一个脚本文件这样通常指的是Bash会产生一个新的shell去运行它
很困惑?别担心 -- 试试这个:创建一个名为 _myscript_ 的脚本,内容包含下面一行
```
myvar="Hello"
```
然后通过常规的方法执行它,也就是用 `sh myscript`(或者通过 `chmod a+x myscript` 命令让它可执行,然后运行`./myscript`)。现在尝试并且观察`myvar` 的内容 ,通过`echo $myvar` 理所当然的你什么也得不到。那是因为当你的脚本赋值“_Hello_”给`myvar`时它是在一个隔离的bash shell实例中进行的。当脚本运行结束时这个新产生的实例会消失并且控制权转交给原来的shell而原来的shell甚至都不存在`myvar` 变量。
然而,如果你这样运行 _myscript_ :
```
. myscript
```
`echo $myvar` 就会打印 _Hello_ 到命令行上。
当你的 _.bashrc_ 文件发生变化后,你经常会用到`.` (或 `source`) 命令, [就像当你要扩展 `PATH` 变量那样][1] 在你的当前shell实例中你使用`.`来让变化立即生效。
### 双重麻烦
就像看似无关紧要的一个点有多个含义一样,两个点也是如此。除了指向当前目录的父级之外,两个点(`..`)也用于构建序列。
尝试下这个:
```
echo {1..10}
```
它会打印出从1到10的序列。这种场景下`..` 表示 “_从左边的值开始计数到右边的值_”.
现在试下这个:
```
echo {1..10..2}
```
你会得到 _1 3 5 7 9_ 。`..2`这部分命令告诉Bash输出这个序列不过不是每个相差1而是相差2。换句话说就是你会得到从1到10之间的奇数。
反着它也仍然有效:
```
echo {10..1..2}
```
你也可以用多个0填充你的数字。这样
```
echo {000..121..2}
```
会这样打印出从0到121之间的偶数
```
000 002 004 006 ... 050 052 054 ... 116 118 120
```
不过这样的序列发生器怎样才有作用呢?当然,假设您的新年决心之一是对您的帐户更加谨慎。 作为其中一部分您需要创建目录以便对过去10年的数字发票进行分类
```
mkdir {2009..2019}_Invoices
```
工作完成。
或者你可能有数百个带编号的文件比如从视频剪辑中提取的帧无论出于什么原因你只想删除第43帧和第61帧之间的每隔三帧
```
rm frame_{043..61..3}
```
很可能如果你有超过100帧它们将以填充0命名如下所示
```
frame_000 frame_001 frame_002 ...
```
那就是为什么你要用 `043` 在你的命令中,而不是`43` 的原因。
### Curly~Wurly
说实话,序列的神奇之处不在于双点,就像花括号(`{}`)的巫术一样。 看看它对于字母是如何工作的。这样做:
```
touch file_{a..z}.txt
```
创建了从 _file_a.txt_ 到 _file_z.txt_ 的文件。
但是,你必须小心。 使用像`{Z..a}`这样的序列将运行大量字母和小写字母之间的一堆非字母数字字符(既不是数字或字母的字形)。 其中一些字形是不可打印的或具有自己的特殊含义。 使用它们来生成文件名称可能会导致一系列意外和可能令人不快的影响。
最后一件值得指出的事:包围在`{...}`的序列,它们也可以包含字符串的列举:
```
touch {blahg, splurg, mmmf}_file.txt
```
创建了 _blahg_file.txt_ , _splurg_file.txt_ and _mmmf_file.txt_.
当然,在别的场景中,大括号也有不同的含义(惊喜!)。不过那是别的文章的内容了。
### 总结
系统管理员开发Bash和你可以在上面使用的工具集已有数十载他们仍在寻找着解决各种特殊问题的方法。要说系统管理员和他们的方式是他们自己的特殊品味将是轻描淡写。总而言之与其他语言相反Bash的设计并不是用户友好简单甚至合乎逻辑的。
这并不意味着它不强大 -- 恰恰相反。 Bash的语法和shell工具可能不一致且庞大但它们也提供了一系列令人眼花缭乱的方法来完成您可能想象到的一切。 就像有一个工具箱,你可以找到从电钻到勺子的所有东西,以及橡皮鸭,一卷胶带和一些指甲钳。
除了引人入胜之外发现你可以直接在shell中实现的所有内容也很有趣所以下次我们将深入探讨如何构建更大更好的Bash命令行。
在那之前,玩得开心!
--------------------------------------------------------------------------------
via: https://www.linux.com/blog/learn/2019/1/linux-tools-meaning-dot
作者:[Paul Brown][a]
选题:[lujun9972][b]
译者:[asche910](https://github.com/asche910)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linux.com/users/bro66
[b]: https://github.com/lujun9972
[1]: https://www.linux.com/blog/learn/2018/12/bash-variables-environmental-and-otherwise