Article of the week: Building the future of the command line
“The cloud is really a whole lot of Unix machines,” Chu says. “And shell is still the best interface we have for the cloud.”
Tip of the week: Using shuf
and xargs
to create a simple dicware app:
/usr/share/dict/words
is a builtin dictionaryshuf
randomizes inputxargs
executes a given command on each input (by default the command isecho
)
# randomly select 5 words from the dictionary:
% shuf -n 5 /usr/share/dict/words
# join the output into one line:
% shuf -n 5 /usr/share/dict/words | xargs # this is equivalent to `xargs -I{} echo {}`
# make multiple passphrases at once:
% shuf -n 15 /usr/share/dict/words | xargs -n 5
# change the delimeter from space to a character:
% shuf -n 5 /usr/share/dict/words | xargs | tr ' ' '-'