Not today...

comments

Snippet

Bash Expansion

Tagged bash , cli

A small post just to share a useful bashism the Brace Expansion. It is really simple to make it works:

for i in {1..50}
do
	echo "Hello World $i"
done

It will print fifty “Hello World”. Ok it seems cool but not amazing? Ok, now the second feature

echo something/{foo,bar}
> something/foo something/bar

Still not amazed, ok now type this one:

cp some_file{,.old}

It will copy your file adding a .old extension. I do a lot of things like this and it saves me a lot of time, so think about it.