string - Looking for a breakdown of echo{,} foo -
how expression {,}
work?
i tried searching around sof on google , man pages bash, yet haven't been able come across explanation this.
from fiddling around expression i've learned it's sort of string copying function.
echo{,} foo >> echo echo foo echo foo{,} >> foo foo
how expression work? there name this? also, can provide practical example use of function?
the "normal" use case brace expansion repeat string substring replaced each element of list given in curly braces:
$ echo file.{txt,dat,log} file.txt file.dat file.log
now, if 1 of list elements empty, string gets printed is:
$ echo file.{txt,dat,} file.txt file.dat file.
a popular use case rename file
$ mv -v file.txt{,.bak} 'file.txt' -> 'file.txt.bak'
this expands mv -v file.txt file.txt.bak
, because first list element empty.
now, if all elements empty in {,}
, string gets printed many times there list elements.
Comments
Post a Comment