#author("2020-09-01T04:06:22+09:00","default:ryuichi","ryuichi")
#author("2020-09-01T04:10:33+09:00","default:ryuichi","ryuichi")
* ブレース展開 [#ub83c2f9]

** ブレース展開とは? [#k03f3181]
 $ echo {foo,bar,baz}
 foo bar baz            # (1)
 
 $ echo foo{,bar,baz}
 foo foobar foobaz      # (2)

- '''{}'''の中に文字列を''','''で区切って列挙すると(1)のようにスペースで空けて展開される
- この時、ブレースの前に文字列を置き、ブレースの中に空文字列を指定することで(2)のような展開になる

** ブレース展開を利用してcpのファイル名を指定する [#rb613169]

 $ touch test.txt
 $ cp test.txt{,.orig}
 $ ls -1
 test.txt
 test.txt.orig

- cpコマンドでファイル名に拡張子(ここでは.orig)を省力化して指定できる

test.txtorig
** 参考 [#x972a07c]
https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html



トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS