Adding a Little Color to Recursive diffs
I have routine need to recursively diff two large directory trees with small changes sprinkled throughout. After staring at pages and pages of one diffed file after another it becomes easy to lose track of what two files' differences I'm looking at.

An easy way to keep track of things is to inject a little color. The way I go about this is:
diff -r old/ new/ | grep --color=always -e '^diff.*' -e '$' | less -R
I pass the output of my recursive diff to grep which I match of every line starting with "diff" — which happens to be every line starting the output of a new set of files. Also, so that I don't throw away all of the output that doesn't start with "diff" I match on the end of every other line, which allows it to be printed but without being colored.
And since we're talking about pages upon pages of output I pipe everything to less, which would normally try and display the color escape sequences, but with the -R option ANSI color sequences are still output in their raw form so my terminal still displays my coloring.

And suddenly what was a wall of single colored text is a little more readable. If you want to go a step further:

In this case I've done a few of things. I'm now displaying lines with differences side by side. Normally this would also display common lines as well, but I've suppressed that for the sake of the mountain of output it would produce. Also, by default diff will cut off a line after 130 characters. With side by side columns this becomes a serious issue, so I've set the column width to the width of the terminal — in this case it doesn't make much of a difference because the window is so small. Lastly, all these new options clutter up my "diff" lines so I've used sed to clean the line up a bit.
diff -ryW $COLUMNS --suppress-common-lines la lb | grep --color=always -e '^diff.*' -e '$' |
sed 's/-ryW.*--suppress-common-lines //' | less -R
The new options:
-yOutput lines side by side-W $COLUMNSsets the width of output to the width of the terminal, you may have to usetput colsif you're not usingBASH--suppress-common-linesprevents every line from being printed when using side by side output
Read more
Resize Virtualbox Ubuntu LVM Storage in MacOS
I've seen examples of how to accomplish this in Windows. The syntax is slightly different on MacOS. I also find the most straightforward way to do this is a little bit scary for those unfamiliar with Linux partitions. This should work on any LVM based *nix VM; I just happened
Testing Syntax Highlighting
echo testing 1 2 3
Coming soon
This is XenSoft, a brand new site by John Westlund that's just getting started. Things will be up and running here shortly, but you can subscribe in the meantime if you'd like to stay up to date and receive emails when new content is published!
Print BASH Array Elements on Separate Lines
Very easy and usually accomplished with a loop: $ array=(red green blue) $ for I in ${array[@]}; do echo $I; done red green blue But we can do better!: $ printf '%s\n' "${array[@]}" or: $ ( IFS=$'\n'; echo "${array[*]}" ) Note the switch to "${array[*]}" from "${array[@]}" (the "quoting" is important!