Skip to content

Instantly share code, notes, and snippets.

@andrew-stclair
Last active January 10, 2023 00:20
Show Gist options
  • Save andrew-stclair/63132ffdc1375472ff95eda4c6160707 to your computer and use it in GitHub Desktop.
Save andrew-stclair/63132ffdc1375472ff95eda4c6160707 to your computer and use it in GitHub Desktop.
Shell short hand

Bash short hand

systemctl start service-{a,b}.service would be equivalent to systemctl start service-a.service service-b.service

systemctl start srv-{1..4}.service would be equivalent to systemctl start srv-1.service srv-2.service srv-3.service srv-4.service

If for example you had multiple wireguard services and wanted to enable both the service and path for each

systemctl enable wg{0..3}.{service,path} would be equivalent to systemctl enable wg0.service wg0.path wg1.service etc...

this trick only works when you can chain multiple arguments one after the other

I have tested the above with both bash and zsh

zsh extends this by allowing the following:

for ip in 192.168.0.{1..254}; curl $ip -I as a crude web server scanner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment