In bash, I can do the following
$ echo bunny{1..6}
bunny1 bunny2 bunny3 bunny4 bunny5 bunny6
Is there a way to achieve the same result in fish?
In bash, I can do the following
$ echo bunny{1..6}
bunny1 bunny2 bunny3 bunny4 bunny5 bunny6
Is there a way to achieve the same result in fish?
The short answer is echo bunny(seq 6)
Longer answer: In keeping with fish's philosophy of replacing magical syntax with concrete commands, we should hunt for a Unix command that substitutes for the syntactic construct {1..6}
. seq
fits the bill; it outputs numbers in some range, and in this case, integers from 1 to 6. fish (to its shame) omits a help page for seq
, but it is a standard Unix/Linux command.
Once we have found such a command, we can leverage command substitutions. The command (foo)bar
performs command substitution, expanding foo
into an array, and may result in multiple arguments. Each argument has 'bar' appended.
seq
if it doesn't exist, as certain parts of fish source depend on it to exist. –
Avertin echo {foo,bar}
or mkdir --parents /tmp/{folder1,folder2,folder3}
results in /tmp/folder1, /tmp/folder2, /tmp/folder3. More info @ fishshell.com/docs/2.0/index.html#expand –
Browning jot -c 26 a z 1
–
Verlie printf '%b' (printf '\\\\x%02X ' (seq 97 122))
–
Pairs touch file{01..10}
, how do you do that in fish
shell? –
Snashall touch file(seq -f %02g 10)
–
Sidney touch file(seq -w 10)
–
Angeliqueangelis © 2022 - 2024 — McMap. All rights reserved.
fish
:fish
does support brace expansion, but only with lists (e.g.,echo b{ar,az}
), not ranges. – Fossil