Index | Archives | About > Tag: sh

Shell Antipatterns

I've been learning stuff about bash rapidly in the last several years, including better and faster ways of accomplishing common tasks. Here are some of my favorites.

Random n lines of a file

Antipattern

ls | shuf | head -n1

Improvement

ls | shuf -n1

I learned this week that the venerable shuf …

© Jamie Luck. Built using Pelican. Theme by Jamie Luck on github.