mirror of
https://github.com/rawiriblundell/wiki.bash-hackers.org
synced 2024-11-02 00:53:07 +01:00
569 lines
34 KiB
Plaintext
569 lines
34 KiB
Plaintext
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr" class="no-js">
|
|
<head><script type="text/javascript" src="/_static/js/bundle-playback.js?v=TPXmWR5s" charset="utf-8"></script>
|
|
<script type="text/javascript" src="/_static/js/wombat.js?v=txqj7nKC" charset="utf-8"></script>
|
|
<script type="text/javascript">
|
|
__wm.init("http://web.archive.org/web");
|
|
__wm.wombat("https://wiki.bash-hackers.org/syntax/expansion/brace?do=edit","20221206144634","http://web.archive.org/","web","/_static/",
|
|
"1670337994");
|
|
</script>
|
|
<link rel="stylesheet" type="text/css" href="/_static/css/banner-styles.css?v=S1zqJCYt" />
|
|
<link rel="stylesheet" type="text/css" href="/_static/css/iconochive.css?v=qtvMKcIJ" />
|
|
<!-- End Wayback Rewrite JS Include -->
|
|
|
|
<meta charset="UTF-8"/>
|
|
<title>Brace expansion [Bash Hackers Wiki]</title>
|
|
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
|
<link rel="shortcut icon" href="/web/20221206144634im_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/images/favicon.ico"/>
|
|
<link rel="apple-touch-icon" href="/web/20221206144634im_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/images/apple-touch-icon.png"/>
|
|
<meta name="generator" content="DokuWiki"/>
|
|
<meta name="robots" content="noindex,nofollow"/>
|
|
<link type="text/css" rel="stylesheet" href="/web/20221206144634cs_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/assets/bootstrap/default/bootstrap.min.css"/>
|
|
<link rel="search" type="application/opensearchdescription+xml" href="/web/20221206144634/https://wiki.bash-hackers.org/lib/exe/opensearch.php" title="Bash Hackers Wiki"/>
|
|
<link rel="start" href="/"/>
|
|
<link rel="contents" href="/syntax/expansion/brace?do=index" title="Sitemap"/>
|
|
<link rel="manifest" href="/web/20221206144634/https://wiki.bash-hackers.org/lib/exe/manifest.php"/>
|
|
<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/web/20221206144634/https://wiki.bash-hackers.org/feed.php"/>
|
|
<link rel="alternate" type="application/rss+xml" title="Current namespace" href="/web/20221206144634/https://wiki.bash-hackers.org/feed.php?mode=list&ns=syntax:expansion"/>
|
|
<link rel="alternate" type="text/html" title="Plain HTML" href="/web/20221206144634/https://wiki.bash-hackers.org/_export/xhtml/syntax/expansion/brace"/>
|
|
<link rel="alternate" type="text/plain" title="Wiki Markup" href="/web/20221206144634/https://wiki.bash-hackers.org/_export/raw/syntax/expansion/brace"/>
|
|
<link rel="stylesheet" type="text/css" href="/web/20221206144634cs_/https://wiki.bash-hackers.org/lib/exe/css.php?t=bootstrap3&tseed=54923c3deda180f2db5bd755cd8fbf1a"/>
|
|
<!--[if gte IE 9]><!-->
|
|
<script type="text/javascript">/*<![CDATA[*/var NS='syntax:expansion';var JSINFO = {"updatable":1,"userreplace":1,"default_macro_string":"","plugins":{"edittable":{"default columnwidth":""}},"move_renameokay":false,"isadmin":0,"isauth":0,"bootstrap3":{"mode":"source","toc":[],"config":{"collapsibleSections":0,"fixedTopNavbar":1,"showSemanticPopup":0,"sidebarOnNavbar":0,"tagsOnTop":1,"tocAffix":1,"tocCollapseOnScroll":1,"tocCollapsed":0,"tocLayout":"default","useAnchorJS":1,"useAlternativeToolbarIcons":1}},"id":"syntax:expansion:brace","namespace":"syntax:expansion","ACT":"source","useHeadingNavigation":1,"useHeadingContent":1};
|
|
/*!]]>*/</script>
|
|
<script type="text/javascript" charset="utf-8" src="/web/20221206144634js_/https://wiki.bash-hackers.org/lib/exe/jquery.php?tseed=23f888679b4f1dc26eef34902aca964f"></script>
|
|
<script type="text/javascript" charset="utf-8" src="/web/20221206144634js_/https://wiki.bash-hackers.org/lib/exe/js.php?t=bootstrap3&tseed=54923c3deda180f2db5bd755cd8fbf1a"></script>
|
|
<script type="text/javascript">/*<![CDATA[*/if (typeof IconifyConfig == 'undefined') { var IconifyConfig = { 'defaultAPI' : '/lib/tpl/bootstrap3/iconify.php?prefix={prefix}&icons={icons}' } }
|
|
/*!]]>*/</script>
|
|
<script type="text/javascript" src="/web/20221206144634js_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/assets/bootstrap/js/bootstrap.min.js"></script>
|
|
<script type="text/javascript" src="/web/20221206144634js_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/assets/anchorjs/anchor.min.js"></script>
|
|
<script type="text/javascript" src="/web/20221206144634js_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/assets/typeahead/bootstrap3-typeahead.min.js"></script>
|
|
<script type="text/javascript" src="/web/20221206144634js_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/assets/iconify/iconify.min.js"></script>
|
|
<script type="text/javascript" src="/web/20221206144634js_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/assets/iconify/plugins/fa.js"></script>
|
|
<!--<![endif]-->
|
|
<style type="text/css">@media screen { body { margin-top: 65px; } #dw__toc.affix { top: 55px; position: fixed !important; } #dw__toc .nav .nav .nav { display: none; } }</style>
|
|
<!--[if lt IE 9]>
|
|
<script type="text/javascript" src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
|
<script type="text/javascript" src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
|
<![endif]-->
|
|
</head>
|
|
<body class="default dokuwiki mode_source tpl_bootstrap3 dw-page-on-panel dw-fluid-container" data-page-id="syntax:expansion:brace"><div class="dokuwiki">
|
|
<header id="dokuwiki__header" class="dw-container dokuwiki container-fluid mx-5">
|
|
<!-- navbar -->
|
|
<nav id="dw__navbar" class="navbar navbar-fixed-top navbar-default" role="navigation">
|
|
|
|
<div class="dw-container container-fluid mx-5">
|
|
|
|
<div class="navbar-header">
|
|
|
|
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
|
|
<a class="navbar-brand d-flex align-items-center" href="/web/20221206144634/https://wiki.bash-hackers.org/start" accesskey="h" title="Bash Hackers Wiki"><img id="dw__logo" class="pull-left h-100 mr-4" alt="Bash Hackers Wiki" src="/web/20221206144634im_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/images/logo.png"/><div class="pull-right"><div id="dw__title">Bash Hackers Wiki</div></div></a>
|
|
</div>
|
|
|
|
<div class="collapse navbar-collapse">
|
|
|
|
|
|
|
|
|
|
<div class="navbar-right" id="dw__navbar_items">
|
|
|
|
|
|
<!-- navbar-searchform -->
|
|
<form action="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace" accept-charset="utf-8" class="navbar-form navbar-left search" id="dw__search" method="get" role="search">
|
|
<div class="input-group">
|
|
<input id="qsearch" autocomplete="off" type="search" placeholder="Search" value="" accesskey="f" name="q" class="form-control" title="[F]"/>
|
|
<div class="input-group-btn">
|
|
<button class="btn btn-default" type="submit" title="Search">
|
|
<span class="iconify" data-icon="mdi:magnify"></span> </button>
|
|
</div>
|
|
|
|
</div>
|
|
<input type="hidden" name="do" value="search"/>
|
|
</form>
|
|
<!-- /navbar-searchform -->
|
|
<!-- tools-menu -->
|
|
<ul class="nav navbar-nav dw-action-icon" id="dw__tools">
|
|
|
|
|
|
<li class="dropdown">
|
|
|
|
<a href="" class="dropdown-toggle" data-target="#" data-toggle="dropdown" title="" role="button" aria-haspopup="true" aria-expanded="false">
|
|
<span class="iconify" data-icon="mdi:wrench"></span> <span class="hidden-lg hidden-md hidden-sm">Tools</span> <span class="caret"></span>
|
|
</a>
|
|
|
|
<ul class="dropdown-menu tools" role="menu">
|
|
|
|
<li class="dropdown-header">
|
|
<span class="iconify" data-icon="mdi:account"></span> User Tools </li>
|
|
|
|
<li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=register" title="Register" rel="nofollow" class="menuitem register"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M15 14c-2.67 0-8 1.33-8 4v2h16v-2c0-2.67-5.33-4-8-4m-9-4V7H4v3H1v2h3v3h2v-3h3v-2m6 2a4 4 0 0 0 4-4 4 4 0 0 0-4-4 4 4 0 0 0-4 4 4 4 0 0 0 4 4z"/></svg><span>Register</span></a></li><li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=login&sectok=" title="Log In" rel="nofollow" class="menuitem login"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M10 17.25V14H3v-4h7V6.75L15.25 12 10 17.25M8 2h9a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2v-4h2v4h9V4H8v4H6V4a2 2 0 0 1 2-2z"/></svg><span>Log In</span></a></li>
|
|
<li class="divider" role="separator"></li>
|
|
|
|
|
|
<li class="dropdown-header">
|
|
<span class="iconify" data-icon="mdi:toolbox"></span> Site Tools </li>
|
|
|
|
<li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=recent" title="Recent Changes [r]" rel="nofollow" accesskey="r" class="menuitem recent"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M15 13h1.5v2.82l2.44 1.41-.75 1.3L15 16.69V13m4-5H5v11h4.67c-.43-.91-.67-1.93-.67-3a7 7 0 0 1 7-7c1.07 0 2.09.24 3 .67V8M5 21a2 2 0 0 1-2-2V5c0-1.11.89-2 2-2h1V1h2v2h8V1h2v2h1a2 2 0 0 1 2 2v6.1c1.24 1.26 2 2.99 2 4.9a7 7 0 0 1-7 7c-1.91 0-3.64-.76-4.9-2H5m11-9.85A4.85 4.85 0 0 0 11.15 16c0 2.68 2.17 4.85 4.85 4.85A4.85 4.85 0 0 0 20.85 16c0-2.68-2.17-4.85-4.85-4.85z"/></svg><span>Recent Changes</span></a></li><li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=media&ns=syntax%3Aexpansion" title="Media Manager" rel="nofollow" class="menuitem media"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M7 15l4.5-6 3.5 4.5 2.5-3L21 15m1-11h-8l-2-2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2M2 6H0v14a2 2 0 0 0 2 2h18v-2H2V6z"/></svg><span>Media Manager</span></a></li><li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=index" title="Sitemap [x]" rel="nofollow" accesskey="x" class="menuitem index"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M3 3h6v4H3V3m12 7h6v4h-6v-4m0 7h6v4h-6v-4m-2-4H7v5h6v2H5V9h2v2h6v2z"/></svg><span>Sitemap</span></a></li>
|
|
<li class="divider" role="separator"></li>
|
|
|
|
|
|
<li class="dropdown-header">
|
|
<span class="iconify" data-icon="mdi:file-document-outline"></span> Page Tools </li>
|
|
|
|
<li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=" title="Show page [v]" rel="nofollow" accesskey="v" class="menuitem show"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M13 9h5.5L13 3.5V9M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m9 16v-2H6v2h9m3-4v-2H6v2h12z"/></svg><span>Show page</span></a></li><li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=revisions" title="Old revisions [o]" rel="nofollow" accesskey="o" class="menuitem revs"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M11 7v5.11l4.71 2.79.79-1.28-4-2.37V7m0-5C8.97 2 5.91 3.92 4.27 6.77L2 4.5V11h6.5L5.75 8.25C6.96 5.73 9.5 4 12.5 4a7.5 7.5 0 0 1 7.5 7.5 7.5 7.5 0 0 1-7.5 7.5c-3.27 0-6.03-2.09-7.06-5h-2.1c1.1 4.03 4.77 7 9.16 7 5.24 0 9.5-4.25 9.5-9.5A9.5 9.5 0 0 0 12.5 2z"/></svg><span>Old revisions</span></a></li><li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=backlink" title="Backlinks" rel="nofollow" class="menuitem backlink"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M10.59 13.41c.41.39.41 1.03 0 1.42-.39.39-1.03.39-1.42 0a5.003 5.003 0 0 1 0-7.07l3.54-3.54a5.003 5.003 0 0 1 7.07 0 5.003 5.003 0 0 1 0 7.07l-1.49 1.49c.01-.82-.12-1.64-.4-2.42l.47-.48a2.982 2.982 0 0 0 0-4.24 2.982 2.982 0 0 0-4.24 0l-3.53 3.53a2.982 2.982 0 0 0 0 4.24m2.82-4.24c.39-.39 1.03-.39 1.42 0a5.003 5.003 0 0 1 0 7.07l-3.54 3.54a5.003 5.003 0 0 1-7.07 0 5.003 5.003 0 0 1 0-7.07l1.49-1.49c-.01.82.12 1.64.4 2.43l-.47.47a2.982 2.982 0 0 0 0 4.24 2.982 2.982 0 0 0 4.24 0l3.53-3.53a2.982 2.982 0 0 0 0-4.24.973.973 0 0 1 0-1.42z"/></svg><span>Backlinks</span></a></li><li class="action"><a href="#dokuwiki__top" title="Back to top [t]" rel="nofollow" accesskey="t" class="menuitem top"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"/></svg><span>Back to top</span></a></li>
|
|
|
|
</ul>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
<!-- /tools-menu -->
|
|
|
|
<ul class="nav navbar-nav">
|
|
|
|
|
|
<li>
|
|
<span class="dw__actions dw-action-icon">
|
|
<a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=register" title="Register" rel="nofollow" class="menuitem register btn btn-success navbar-btn"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M15 14c-2.67 0-8 1.33-8 4v2h16v-2c0-2.67-5.33-4-8-4m-9-4V7H4v3H1v2h3v3h2v-3h3v-2m6 2a4 4 0 0 0 4-4 4 4 0 0 0-4-4 4 4 0 0 0-4 4 4 4 0 0 0 4 4z"/></svg><span class=""> Register</span></a><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=login&sectok=" title="Log In" rel="nofollow" class="menuitem login btn btn-default navbar-btn"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M10 17.25V14H3v-4h7V6.75L15.25 12 10 17.25M8 2h9a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2v-4h2v4h9V4H8v4H6V4a2 2 0 0 1 2-2z"/></svg><span class=""> Log In</span></a> </span>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<!-- navbar -->
|
|
<div align="center">
|
|
<script async src="//web.archive.org/web/20221206144634js_/https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
|
<!-- BHORG_BOTTOM -->
|
|
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-4658830517838678" data-ad-slot="1603598940"></ins>
|
|
<script>
|
|
(adsbygoogle = window.adsbygoogle || []).push({});
|
|
</script>
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<a name="dokuwiki__top" id="dokuwiki__top"></a>
|
|
|
|
<main role="main" class="dw-container pb-5 dokuwiki container-fluid mx-5">
|
|
|
|
<div id="dokuwiki__pageheader">
|
|
|
|
|
|
<!-- breadcrumbs -->
|
|
<nav id="dw__breadcrumbs" class="small">
|
|
|
|
<hr/>
|
|
|
|
<div class="dw__youarehere">
|
|
<ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li>You are here</li><li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a href="/web/20221206144634/https://wiki.bash-hackers.org/start" itemprop="item" title="start"><span itemprop="name"><span class="iconify" data-icon="mdi:home"></span></span></a></li><li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/start" class="wikilink1" title="syntax:start">Syntax</a></li><li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/start" class="wikilink1" title="syntax:expansion:start">Syntax: Expansions</a></li><li class="active" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><span itemprop="name"><a itemprop="item" href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace" class="wikilink1" title="syntax:expansion:brace">Brace expansion</a></span></li></ol> </div>
|
|
|
|
<div class="dw__breadcrumbs hidden-print">
|
|
<ol class="breadcrumb"><li>Trace</li> </div>
|
|
|
|
<hr/>
|
|
|
|
</nav>
|
|
<!-- /breadcrumbs -->
|
|
|
|
<p class="text-right">
|
|
<span class="pageId ml-1 label label-primary">syntax:expansion:brace</span> </p>
|
|
|
|
<div id="dw__msgarea" class="small">
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
|
|
<article id="dokuwiki__content" class="col-sm-12 col-md-12 " itemscope itemtype="http://schema.org/Article" itemref="dw__license">
|
|
|
|
|
|
<!-- page-tools -->
|
|
<nav id="dw__pagetools" class="hidden-print">
|
|
<div class="tools panel panel-default">
|
|
<ul class="nav nav-stacked nav-pills text-muted">
|
|
<li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=" title="Show page [v]" rel="nofollow" accesskey="v" class="menuitem show"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M13 9h5.5L13 3.5V9M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m9 16v-2H6v2h9m3-4v-2H6v2h12z"/></svg><span>Show page</span></a></li><li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=revisions" title="Old revisions [o]" rel="nofollow" accesskey="o" class="menuitem revs"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M11 7v5.11l4.71 2.79.79-1.28-4-2.37V7m0-5C8.97 2 5.91 3.92 4.27 6.77L2 4.5V11h6.5L5.75 8.25C6.96 5.73 9.5 4 12.5 4a7.5 7.5 0 0 1 7.5 7.5 7.5 7.5 0 0 1-7.5 7.5c-3.27 0-6.03-2.09-7.06-5h-2.1c1.1 4.03 4.77 7 9.16 7 5.24 0 9.5-4.25 9.5-9.5A9.5 9.5 0 0 0 12.5 2z"/></svg><span>Old revisions</span></a></li><li class="action"><a href="/web/20221206144634/https://wiki.bash-hackers.org/syntax/expansion/brace?do=backlink" title="Backlinks" rel="nofollow" class="menuitem backlink"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M10.59 13.41c.41.39.41 1.03 0 1.42-.39.39-1.03.39-1.42 0a5.003 5.003 0 0 1 0-7.07l3.54-3.54a5.003 5.003 0 0 1 7.07 0 5.003 5.003 0 0 1 0 7.07l-1.49 1.49c.01-.82-.12-1.64-.4-2.42l.47-.48a2.982 2.982 0 0 0 0-4.24 2.982 2.982 0 0 0-4.24 0l-3.53 3.53a2.982 2.982 0 0 0 0 4.24m2.82-4.24c.39-.39 1.03-.39 1.42 0a5.003 5.003 0 0 1 0 7.07l-3.54 3.54a5.003 5.003 0 0 1-7.07 0 5.003 5.003 0 0 1 0-7.07l1.49-1.49c-.01.82.12 1.64.4 2.43l-.47.47a2.982 2.982 0 0 0 0 4.24 2.982 2.982 0 0 0 4.24 0l3.53-3.53a2.982 2.982 0 0 0 0-4.24.973.973 0 0 1 0-1.42z"/></svg><span>Backlinks</span></a></li><li class="action"><a href="#dokuwiki__top" title="Back to top [t]" rel="nofollow" accesskey="t" class="menuitem top"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"/></svg><span>Back to top</span></a></li> </ul>
|
|
</div>
|
|
</nav>
|
|
<!-- /page-tools -->
|
|
|
|
<div class="panel panel-default px-3 py-2" itemprop="articleBody">
|
|
<div class="page panel-body">
|
|
|
|
|
|
<div class="dw-content-page "><!-- content --><div class="dw-content"><p>
|
|
This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong.
|
|
</p>
|
|
<div class="editBox" role="application">
|
|
|
|
<div class="toolbar group">
|
|
<div id="draft__status" class="draft__status"></div>
|
|
<div id="tool__bar" class="tool__bar"></div>
|
|
</div>
|
|
<form id="dw__editform" method="post" action="" accept-charset="utf-8" class=" form-inline"><div class="no">
|
|
<input type="hidden" name="sectok" value=""/><input type="hidden" name="id" value="syntax:expansion:brace"/><input type="hidden" name="rev" value="0"/><input type="hidden" name="date" value="0"/><input type="hidden" name="prefix" value="."/><input type="hidden" name="suffix" value=""/><input type="hidden" name="changecheck" value="7cf44fa53726f2e6a9ae2def38e73f15"/><input type="hidden" name="target" value="section"/><textarea name="wikitext" id="wiki__text" dir="auto" class="edit form-control" cols="80" rows="10" tabindex="1" readonly="readonly">
|
|
====== Brace expansion ======
|
|
|
|
{{keywords>bash shell scripting expansion substitution text list brace}}
|
|
|
|
<code>
|
|
{string1,string2,...,stringN}
|
|
{<START>..<END>}
|
|
|
|
{<START>..<END>..<INCR>} (Bash 4)
|
|
|
|
<PREFIX>{........}
|
|
|
|
{........}<SUFFIX>
|
|
|
|
<PREFIX>{........}<SUFFIX>
|
|
</code>
|
|
|
|
Brace expansion is used to generate arbitrary strings. The specified strings are used to generate **all possible combinations** with the optional surrounding prefixes and suffixes.
|
|
|
|
Usually it's used to generate mass-arguments for a command, that follow a specific naming-scheme.
|
|
|
|
:!: It is the very first step in expansion-handling, it's important to understand that. When you use
|
|
<code>
|
|
echo {a,b}$PATH
|
|
</code>
|
|
then the brace expansion **does not expand the variable** - this is done in a **later step**. Brace expansion just makes it being:
|
|
<code>
|
|
echo a$PATH b$PATH
|
|
</code>
|
|
Another common pitfall is to assume that a range like ''{1..200}'' can be expressed with variables using ''{$a..$b}''. Due to what I described above, it **simply is not possible**, because it's the very first step in doing expansions. A possible way to achieve this, if you really can't handle this in another way, is using the ''eval'' command, which basically evaluates a commandline twice: <code>eval echo {$a..$b}</code> For instance, when embedded inside a for loop : <code>for i in $(eval echo {$a..$b})</code> This requires that the entire command be properly escaped to avoid unexpected expansions. If the sequence expansion is to be assigned to an array, another method is possible using [[commands:builtin:declare|declaration commands]]: <code>declare -a 'pics=(img{'"$a..$b"'}.png)'; mv "${pics[@]}" ../imgs</code> This is significantly safer, but one must still be careful to control the values of $a and $b. Both the exact quoting, and explicitly including "-a" are important.
|
|
|
|
The brace expansion is present in two basic forms, **string lists** and **ranges**.
|
|
|
|
It can be switched on and off under runtime by using the ''set'' builtin and the option ''-B'' and ''+B'' or the long option ''braceexpand''. If brace expansion is enabled, the stringlist in ''SHELLOPTS'' contains ''braceexpand''.
|
|
|
|
===== String lists =====
|
|
|
|
<code>
|
|
{string1,string2,...,stringN}
|
|
</code>
|
|
|
|
Without the optional prefix and suffix strings, the result is just a space-separated list of the given strings:
|
|
<code>
|
|
$ echo {I,want,my,money,back}
|
|
I want my money back
|
|
</code>
|
|
|
|
With prefix or suffix strings, the result is a space-separated list of **all possible combinations** of prefix or suffix specified strings:
|
|
<code>
|
|
$ echo _{I,want,my,money,back}
|
|
_I _want _my _money _back
|
|
|
|
$ echo {I,want,my,money,back}_
|
|
I_ want_ my_ money_ back_
|
|
|
|
$ echo _{I,want,my,money,back}-
|
|
_I- _want- _my- _money- _back-
|
|
</code>
|
|
|
|
The brace expansion is only performed, if the given string list is really a **list of strings**, i.e., if there is a minimum of one "'',''" (comma)! Something like ''{money}'' doesn't expand to something special, it's really only the text "''{money}''".
|
|
|
|
===== Ranges =====
|
|
|
|
<code>
|
|
{<START>..<END>}
|
|
</code>
|
|
|
|
Brace expansion using ranges is written giving the startpoint and the endpoint of the range. This is a "sequence expression". The sequences can be of two types
|
|
* integers (optionally zero padded, optionally with a given increment)
|
|
* characters
|
|
|
|
<code>
|
|
$ echo {5..12}
|
|
5 6 7 8 9 10 11 12
|
|
|
|
$ echo {c..k}
|
|
c d e f g h i j k
|
|
</code>
|
|
|
|
When you mix these both types, brace expansion is **not** performed:
|
|
<code>
|
|
$ echo {5..k}
|
|
{5..k}
|
|
</code>
|
|
|
|
When you zero pad one of the numbers (or both) in a range, then the generated range is zero padded, too:
|
|
<code>
|
|
$ echo {01..10}
|
|
01 02 03 04 05 06 07 08 09 10
|
|
</code>
|
|
There's a chapter of Bash 4 brace expansion changes at [[#new_in_bash_4.0 | the end of this article]].
|
|
|
|
Similar to the expansion using stringlists, you can add prefix and suffix strings:
|
|
<code>
|
|
$ echo 1.{0..9}
|
|
1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
|
|
|
|
$ echo ---{A..E}---
|
|
---A--- ---B--- ---C--- ---D--- ---E---
|
|
</code>
|
|
|
|
===== Combining and nesting =====
|
|
|
|
When you combine more brace expansions, you effectively use a brace expansion as prefix or suffix for another one. Let's generate all possible combinations of uppercase letters and digits:
|
|
<code>
|
|
$ echo {A..Z}{0..9}
|
|
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 C0 C1 C2 C3 C4 C5 C6
|
|
C7 C8 C9 D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 F0 F1 F2 F3
|
|
F4 F5 F6 F7 F8 F9 G0 G1 G2 G3 G4 G5 G6 G7 G8 G9 H0 H1 H2 H3 H4 H5 H6 H7 H8 H9 I0
|
|
I1 I2 I3 I4 I5 I6 I7 I8 I9 J0 J1 J2 J3 J4 J5 J6 J7 J8 J9 K0 K1 K2 K3 K4 K5 K6 K7
|
|
K8 K9 L0 L1 L2 L3 L4 L5 L6 L7 L8 L9 M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 N0 N1 N2 N3 N4
|
|
N5 N6 N7 N8 N9 O0 O1 O2 O3 O4 O5 O6 O7 O8 O9 P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 Q0 Q1
|
|
Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 S0 S1 S2 S3 S4 S5 S6 S7 S8
|
|
S9 T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 U0 U1 U2 U3 U4 U5 U6 U7 U8 U9 V0 V1 V2 V3 V4 V5
|
|
V6 V7 V8 V9 W0 W1 W2 W3 W4 W5 W6 W7 W8 W9 X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 Y0 Y1 Y2
|
|
Y3 Y4 Y5 Y6 Y7 Y8 Y9 Z0 Z1 Z2 Z3 Z4 Z5 Z6 Z7 Z8 Z9
|
|
</code>
|
|
Hey.. that **saves you writing** 260 strings!
|
|
|
|
Brace expansions can be nested, but too much of it usually makes you losing overview a bit ;-)
|
|
|
|
Here's a sample to generate the alphabet, first the uppercase letters, then the lowercase ones:
|
|
<code>
|
|
$ echo {{A..Z},{a..z}}
|
|
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z
|
|
</code>
|
|
|
|
===== Common use and examples =====
|
|
|
|
==== Massdownload from the Web ====
|
|
In this example, ''wget'' is used to download documentation that is split over several numbered webpages.
|
|
|
|
''wget'' won't see your braces. It will see **6 different URLs** to download.
|
|
|
|
<code>
|
|
wget http://docs.example.com/documentation/slides_part{1,2,3,4,5,6}.html
|
|
</code>
|
|
|
|
Of course it's possible, and even easier, to do that with a sequence:
|
|
|
|
<code>
|
|
wget http://docs.example.com/documentation/slides_part{1..6}.html
|
|
</code>
|
|
|
|
|
|
|
|
==== Generate a subdirectory structure ====
|
|
|
|
Your life is hard? Let's ease it a bit - that's what shells are here for.
|
|
|
|
<code>
|
|
mkdir /home/bash/test/{foo,bar,baz,cat,dog}
|
|
</code>
|
|
|
|
|
|
|
|
==== Generate numbers with a prefix 001 002 ... ====
|
|
* Using a prefix:
|
|
<code>
|
|
for i in 0{1..9} 10; do printf "%s\n" "$i";done
|
|
</code>
|
|
If you need to create words with the number embedded, you can use nested brace:
|
|
<code>
|
|
printf "%s\n" img{00{1..9},0{10..99},{100..999}}.png
|
|
</code>
|
|
* Formatting the numbers with printf:
|
|
<code>
|
|
echo $(printf "img%02d.png " {1..99})
|
|
</code>
|
|
|
|
See the [[#news_in_bash_4.0 | text below]] for a new Bash 4 method.
|
|
|
|
==== Repeating arguments or words ====
|
|
|
|
<code>
|
|
somecommand -v -v -v -v -v
|
|
</code>
|
|
|
|
Can be written as
|
|
<code>
|
|
somecommand -v{,,,,}
|
|
</code>
|
|
...which is a kind of a hack, but hey, it works.
|
|
|
|
<div round info>
|
|
=== More fun ===
|
|
The most optimal possible brace expansion to expand n arguments of course consists of n's prime factors. We can use the "factor" program bundled with GNU coreutils to emit a brace expansion that will expand any number of arguments.
|
|
|
|
<code>
|
|
function braceify {
|
|
[[ $1 == +([[:digit:]]) ]] || return
|
|
typeset -a a
|
|
read -ra a < <(factor "$1")
|
|
eval "echo $(printf '{$(printf ,%%.s {1..%s})}' "${a[@]:1}")"
|
|
}
|
|
|
|
printf 'eval printf "$arg"%s' "$(braceify 1000000)"
|
|
</code>
|
|
|
|
"Braceify" generates the expansion code itself. In this example we inject that output into a template which displays the most terse brace expansion code that would expand ''"$arg"'' 1,000,000 times if evaluated. In this case, the output is:
|
|
|
|
<code>
|
|
eval printf "$arg"{,,}{,,}{,,}{,,}{,,}{,,}{,,,,,}{,,,,,}{,,,,,}{,,,,,}{,,,,,}{,,,,,}
|
|
</code>
|
|
</div>
|
|
===== New in Bash 4.0 =====
|
|
|
|
==== Zero padded number expansion ====
|
|
|
|
Prefix either of the numbers in a numeric range with ''0'' to pad the expanded numbers with the correct amount of zeros:
|
|
<code>
|
|
$ echo {0001..5}
|
|
0001 0002 0003 0004 0005
|
|
</code>
|
|
|
|
==== Increment ====
|
|
It is now possible to specify an increment using ranges:
|
|
<code>
|
|
{<START>..<END>..<INCR>}
|
|
</code>
|
|
''<INCR>'' is numeric, you can use a negative integer but the correct sign is deduced from the order of ''<START>'' and ''<END>'' anyways.
|
|
<code>
|
|
$ echo {1..10..2}
|
|
1 3 5 7 9
|
|
$ echo {10..1..2}
|
|
10 8 6 4 2
|
|
</code>
|
|
|
|
Interesting feature: The increment specification also works for letter-ranges:
|
|
<code>
|
|
$ echo {a..z..3}
|
|
a d g j m p s v y
|
|
</code>
|
|
|
|
===== See also =====
|
|
* [[syntax:expansion:intro | Introduction to expansion and substitution]]</textarea>
|
|
<div id="wiki__editbar" class="editBar">
|
|
<div id="size__ctl">
|
|
</div>
|
|
</div>
|
|
</div></form>
|
|
</div>
|
|
</div><!-- /content --></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="small text-right">
|
|
|
|
<span class="docInfo">
|
|
<ul class="list-inline"><li><span class="iconify text-muted" data-icon="mdi:file-document-outline"></span> <span title="syntax/expansion/brace.txt">syntax/expansion/brace.txt</span></li><li><span class="iconify text-muted" data-icon="mdi:calendar"></span> Last modified: <span title="2020/06/28 01:16">2020/06/28 01:16</span></li><li class="text-muted">by <bdi>fgrose</bdi></li></ul> </span>
|
|
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
<footer id="dw__footer" class="dw-container py-5 dokuwiki container-fluid">
|
|
<hr/>
|
|
<div align="center">
|
|
<h3><a target="_blank" href="http://web.archive.org/web/20221206144634/http://www.performing-databases.com/">This site is supported by Performing Databases - your experts for database administration</a></h3>
|
|
</div>
|
|
<hr/>
|
|
<div align="center">
|
|
<script async src="//web.archive.org/web/20221206144634js_/https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
|
<!-- BHORG_BOTTOM -->
|
|
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-4658830517838678" data-ad-slot="1603598940"></ins>
|
|
<script>
|
|
(adsbygoogle = window.adsbygoogle || []).push({});
|
|
</script>
|
|
</div>
|
|
|
|
<!-- footer -->
|
|
<div class="dw-container small container-fluid mx-5">
|
|
|
|
|
|
<div class="footer-dw-title">
|
|
<div class="media">
|
|
<div class="media-left">
|
|
<img src="/web/20221206144634im_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/images/logo.png" alt="Bash Hackers Wiki" class="media-object" style="height:32px"/>
|
|
</div>
|
|
<div class="media-body">
|
|
<div class="row">
|
|
<div class="col-sm-2">
|
|
<h4 class="media-heading">Bash Hackers Wiki</h4>
|
|
<p>
|
|
</p>
|
|
</div>
|
|
<div class="col-sm-10">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer-license row">
|
|
<hr/>
|
|
<div id="dw__license" class="col-sm-6">
|
|
<p>
|
|
<a href="http://web.archive.org/web/20221206144634/http://www.gnu.org/licenses/fdl-1.3.html" title="GNU Free Documentation License 1.3" target="" itemscope itemtype="http://schema.org/CreativeWork" itemprop="license" rel="license" class="license"><img src="/web/20221206144634im_/https://wiki.bash-hackers.org/lib/tpl/bootstrap3/images/license/gnufdl.png" width="24" height="24" alt="gnufdl"/> </a> </p>
|
|
<p class="small">
|
|
Except where otherwise noted, content on this wiki is licensed under the following license:<br/><a href="http://web.archive.org/web/20221206144634/http://www.gnu.org/licenses/fdl-1.3.html" title="GNU Free Documentation License 1.3" target="" itemscope itemtype="http://schema.org/CreativeWork" itemprop="license" rel="license" class="license">GNU Free Documentation License 1.3</a> </p>
|
|
</div>
|
|
|
|
<div class="col-sm-6">
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<!-- /footer -->
|
|
</footer>
|
|
|
|
<a href="#dokuwiki__top" class="back-to-top hidden-print btn btn-default" title="skip to content" accesskey="t">
|
|
<span class="iconify" data-icon="mdi:chevron-up"></span> </a>
|
|
|
|
<div id="screen__mode"> <span class="visible-xs-block"></span>
|
|
<span class="visible-sm-block"></span>
|
|
<span class="visible-md-block"></span>
|
|
<span class="visible-lg-block"></span>
|
|
</div>
|
|
|
|
<img src="/web/20221206144634im_/https://wiki.bash-hackers.org/lib/exe/indexer.php?id=syntax%3Aexpansion%3Abrace&1670338023" width="2" height="1" alt=""/>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|
|
<!--
|
|
FILE ARCHIVED ON 14:46:34 Dec 06, 2022 AND RETRIEVED FROM THE
|
|
INTERNET ARCHIVE ON 11:36:38 Apr 14, 2023.
|
|
JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
|
|
|
|
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
|
|
SECTION 108(a)(3)).
|
|
-->
|
|
<!--
|
|
playback timings (ms):
|
|
captures_list: 100.797
|
|
exclusion.robots: 0.157
|
|
exclusion.robots.policy: 0.144
|
|
cdx.remote: 0.077
|
|
esindex: 0.009
|
|
LoadShardBlock: 71.943 (3)
|
|
PetaboxLoader3.datanode: 66.437 (4)
|
|
load_resource: 709.75
|
|
PetaboxLoader3.resolve: 681.798
|
|
--> |