问题标签 [brace-expansion]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
bash - 在给定数字的情况下增加大括号扩展的数量
我有一个使用大括号扩展的程序:
我想用提供的数字增加大括号扩展中使用的字母数量。例如,如果提供了数字 3:
如果提供了数字 5:
我怎样才能在 bash 中做到这一点?
bash - 循环遍历单词的不同变体
我想遍历一个单词的不同变体,但想不出语法将如何排列,例如:
会返回:
我将如何构建该循环?
arrays - 反转 shell 式大括号扩展
大括号扩展采用一个模式并将其扩展。例如:
扩展为:
是否有一种算法(可能使用 JavaScript 实现)以最小化构造字符串的方式进行反向操作?
即,接受一个数组[spell spill spall]
并返回一个字符串"sp{e,i,a}ll"
bash - 使用fish shell一次创建多个文件
我正在尝试使用这种语法一次创建几个文件touch foo{0..9}
,我想要的输出是从 0 到 9 编号的十个文件,但这仅在我使用 bash 时有效,如果我切换到fish,它会创建一个像这样的文件“foo1..9”。
操作系统是 Debian 9 4.9.0-8-amd64,fish 版本是 2.7.1
node.js - 带有大括号扩展的 NodeJS Exec cp 给出了不同的结果。为什么?
我有一个 grunt-shell 命令,它使用大括号扩展 cp 图像文件。
当我在 MacOS 上运行这个 grunt-shell 命令时,它会执行预期的操作,但会在 ubuntu 上返回“cannot cp ...”错误。
我搜索了 grunt-shell lib,发现它使用了 exec 函数。我在受控环境中再次测试了该命令
exec('cp ./app/images/{*.png,*.jpg,*.ico} tmp/images')
并且经过验证的 exec 函数的 spawn args 是相同的:
['/bin/sh', '-c', 'cp ./app/images/{*.png,*.jpg,*.ico} tmp/images']
我在 ubuntu 服务器终端中成功执行了命令。所以我的问题是 nodejs 在不同环境中处理大括号扩展的问题,我可以将哪些选项传递给 nodejs 以使该命令跨 unix 操作系统工作?
bash - mv brace expansion with globbing in script
I'm trying to move photos to a different directory. It works great when I run mv
from the command line (in bash and zsh):
I wrote this bash script that moves a series of photos to a different directory.
But not if I run it from a script:
.
./new/STACK_2385-2387
is being created. The relevant *.NEF
raws and *.NEF.xmp
sidecar files also exist, including 2385, 2386, and 2387, so it's not an issue there.
linux - What is the difference between these two things?
I just wanted to know what is the difference between:
echo {$number1..$number2}
AND
eval echo {$number1..$number2}
Of course, imagine that there is a value in $number1 and $number2. With the first option is just not working, but with the second option it works. I'm not the typical guy that only want something to work, I want to understand why it happens like that so, why exactly is this happening like this?
linux - 变量/参数扩展中的字符串项
我正在尝试使用变量,而不是在多个地方明确列出我的区域列表。
我意识到我可以下载所有文件,然后应用我正在寻找的文件。我觉得我应该能够做到这一点,我想这会让这有点学术练习。也许我的术语已经关闭,但我所做的大部分搜索都是基于整数的结果。下面的代码按原样工作......但我想{ru,cn...}
用一个$zone_list
变量换掉。这就像文件扩展名或类型一样容易{jpg,php,htm,html}
......我在这里偏离基地,还是我应该考虑另一种方式?
编辑:使用下面 Dzienny 的答案更新脚本
makefile - Makefile.am 中的变量扩展错误
我被一个奇怪的变量扩展困住了。让我解释。
我有一个使用 automake 的项目,由 ,configure.ac
组成Makefile.am
。基本上,在Makefile.am
我正在做的事情中:
./arch 只是uname -m
为了确定所需的架构,因为我必须输入正确的目录。
当我运行构建时,我有这个错误:
如果我进入该license
目录,我会注意到创建了一个新目录,名为${ARCH}/
where I find the missing .deps
from license/x86_64
。
我很确定这是一个不正确的扩展问题;我尝试了很多方法,但我失败了。
谁能向我解释这样做的正确方法?在网上阅读,我发现它Makefile.am
的语法与Makefile
.
更新:
我尝试添加一些更改以查看变量是否正确定义:
AC_DEFINE([ARCH], ["$ARCH"], [arch check])
echo ARCH = "$ARCH"
printfx86_64
所以在configure.ac 中定义的变量,但在Makefile.am 中扩展又不正确。
linux - 是否可以将程序输出用作大括号扩展的值?
我是一个linux新手。我想知道您是否可以使用程序的输出(即逗号分隔值)作为将用于大括号扩展的值。
我主要是尝试通过触摸来做到这一点,但开始使用 echo 来测试不同的方法,但没有运气。基本方法是
我也试过 cat 但得到了相同的结果。find 的输出用作大括号的单个值,而不是多个逗号分隔值。我验证了这一点
有了这个我得到2个输出b /(用逗号分隔的值列表从find)和b / otherValue
我能够在当前工作文件夹中通过触摸创建文件,我想看看是否可以在另一个文件夹中执行此操作。