Prefetch Technologies // Keeping your cache lines cozy

Archive

Posts in Shell

Having fun in the shell with cowsay and fortune

shellJan 25, 2017 1 min read

Last weekend while I was waiting for several ansible playbooks to apply I thought it would be fun to play around with cowsay and fortune. If you aren't familiar with these tools cowsay gives you an ASCII cow which says whatever is passed to it as an argument. Here is a example: To have a cowtastic time each time I open a shell I added the following to my bashrc: I guess the old saying is right. All work and no play makes an admin mooooooooo…

$ read more →

Automatically updating your .bashrc when you log into a server

shellJan 25, 2017 1 min

I am a long time bash user and have found numerous aliases and shell functions that allow me to be more productive at the prompt. Depending on how you manage (configuration management, NFS mounted home directories, etc.) ${HOME} making sure your bashrc gets updated when you find a cool new feature can be a pain. I was tinkering around last weekend and thought about adding a block of code to my bashrc to run curl to grab the latest version of my bashrc from github. The following short code block works for my needs: If a new version is available (a VERSION variable tracks the release #) I get the following output when I log in: If github is unavailable due to a service issue or a firewall won't let me out the script will let me know: How are you keeping your shell profiles up to date…

$ read more →

Fun times with the bash read function and subshells

shellOct 29, 2011 1 min

There are a few shellisms that have bitten me over the years. One issue that has bitten me more than once is the interation of variable assignments when a pipe is used to pass data to a subshell. This annoyance can be easily illustrated with an example: On first glance you would think that the echo statement would display the total amount of memory in the system. But alas, it produces nothing…

$ read more →

Finding approximate matches in a data file with agrep

linuxshellDec 27, 2010 1 min

A few weeks back I ran into a situation that required me to locate a data given a file with various variations of that data. I proceeded to grep for each form of the string (e.g., "the", "the", "tte") I could think of, but wasn't getting the results I wanted. After a bit of poking around, I came across the incredibly useful agrep utility. This utility allows you to look for approximate matches in files, specifying the number of variations that can occur…

$ read more →

Sorting data by dates, numbers and much much more

shellJun 24, 2010 1 min

Every year or two I try to re-read manual pages and documentation about my favorite UNIX tools (bash, awk, sed, grep, etc.). Each time I do this I pick up some cool new nugget of information, and refresh my mind on things that I may have forgot. While reading through an article on sort, I came across the following note about the sort "-k" (field to sort by) option: "Further modifications of the sorting algorithm are possible with these options: -d (use only letters, digits, and blanks for sort keys), -f (turn off case recognition and treat lowercase and uppercase characters as identical), -i (ignores non-printing ASCII characters), -M (sorts lines using three-letter abbreviations of month names: JAN, FEB, MAR, ...), -n (sorts lines using only digits, -, and commas, or other thousands separator). These options, as well as -b and -r, can be used as part of a key number, in which case they apply to that key only and not globally, like they do when they are used outside key definitions."* This is crazy useful, and I didn't realize sort could be used to sort by date…

$ read more →