Posts

Showing posts with the label TIL

TIL: Keeping parent directory structure while copying

There had been instances when I wanted to copy "/home/roy" to a target directory "/target" as "/target/home/roy". I used to do some scripting foo to get this done. A few days back, I learned this cool option called "--parents" in cp command that will preserve the parent directory structure while copying. Made my life a lot easier on one of my backup tasks.

Today I Learned (TIL)

Today I Learned (TIL) is a series of posts that contain bit sized information that I learned and found to be worthy of sharing with others and keep as a note to myself. For the last couple of years, I had been devoting most of my time in building the start-up, Zycada Networks , that I co-founded. It makes me happy to share my knowledge. So I would like to get back to the habit of writing blog posts regularly on interesting stories, tips-and-tricks, new ideas, technology trends, etc. TIL is one part of doing it.

TIL: Sort human friendly values

Sorting numeric values in the input is easy. It just takes "sort -n". But what if the input contains human friendly units. For intance, "5G", "3M", "4K", etc. There is a flag to recognize and sort based on the human friendly units: "-h". Incorrect: du -h | sort -nr Correct: du -h | sort -rh Caveat: "sort -h" works only on upper-case units. "K" will be treated as kilos, but "k" will not be!