在cat命令语法奇怪 [英] Strange grammar in cat command

查看:134
本文介绍了在cat命令语法奇怪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我很抱歉,如果这个问题可以通过网络搜索来回答,但我无法找到任何东西。

First of all, I apologize if this question can be answered with a web search, but I couldn't find anything.

有是我所见过的重复文件cat命令语法部分。

There is some grammar in the cat command which I've seen to "repeat" files.

cat file{,}

等同于调用

cat file file

此外,

cat file{,}{,}{,}{,}

重复文件不四次,但16倍。
此外,

repeats file not four times, but 16 times. In addition,

cat file{,,}

重复文件 3倍。

我想更多地了解这个语法。这叫什么?它是内置到猫或者是抽壳特征?是否有这种语法更多的功能?

I would like to know more about this grammar. What is it called? Is it built into cat or is it a shell feature? Are there more features of this grammar?

推荐答案

此功能被称为的括号扩展

一般来说,你可以写文件{1,2,3} 和之前的bash它扩展到文件1文件2文件3 运行该命令。

Generally you can write file{1,2,3} and bash expands it to file1 file2 file3 before running the command.

如果你写

mkdir foo{1,2,3}{a,b}

这将是等同于

mkdir foo1a foo1b foo2a foo2b foo3a foo3b

和将创建的6目录。

在您的情况下( {,} )要添加什么,没有什么,因此获得两倍的同一个词。

In your case ({,}) you are adding nothing and nothing and therefore get the same word twice.

这篇关于在cat命令语法奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆