Twitter (not set)
Blog (not set)


Generate a sequence of numbers

 $ echo {01..10} # 01 02 03 04 05 06 07 08 09 10

— by Elkku on March 1, 2015, 12:04 a.m.


While the original one-liner is indeed IMHO the canonical way to loop over numbers, the brace expansion syntax of bash 4.x has some kick-ass features such as correct padding of the number with leading zeros.


Limited to bash (>=4.x).


Run a command and copy its output to clipboard (Mac OSX)

 $ echo "Here comes the output of my failing code" | tee >(pbcopy)

— by Elkku on Feb. 28, 2015, 11:53 p.m.


Often you need to copy the output of a program for debugging purposes. Cool kids on the block may use pastebin servers. But what if you'd just like to copy-and-paste the output to a web form, say?

This one-liner gives a nice demonstration of process substitution. The stdout is piped to tee for duplication. Rather than dumping the output to a file as in the normal case, the output is piped to pbcopy via a temporary file that the OS conjures up on the fly (/dev/fd/XXX). The end result: you can paste the output wherever you want with Command+V.


This is Mac OSX specific. Use xsel on Linux.