BASH, SED & AWK
BASH, SED & AWK
Let's play with the magical number discovered by mathematics school teacher, Kaprekar: 6174
When we take any 4 random digits, of which at least 1 must be different from the other 3, arrange them from smallest to largest, and then subtract it from the same set of digits that have been arranged from largest to smallest, the result may well be 6174. If the result if not this number, then use that last result and arrange them into 2 numbers in the same way and subtract them from each other. Repeat these steps until the result is 6174. Once you get to this value, subsequent iterations just deliver the same result of 6174.
This quirky routine works for all numbers between 1 and 9998, excluding the repdigits 1111,2222,3333, etc.
Sometimes, it takes only 1 such iteration, sometimes more. Is it possible to determine in advance how many such iterations are required to reach the convergence to 6174?
Read more: Visualizing the convergence to Kaprekar's Constant 6174
I was given a USB stick with 16,000 PowerPoint files with the .ppt extension dating from 2005, of which each document is a manually scanned page of sheet music. This was done by a very diligent soul all those years ago, who knew little of the pernicious ways how Big Tech operate by regularly changing the data formats of digital artefacts, which forces users to constantly upgrade their expensive software. No surprise then that files produced by the version of PowerPoint from back in 2005 are not recognised by the more recent versions of the PowerPoint application.
Read more: Filename Data Cleansing with BASH, PDFTK & LibreOffice
Check this out! Impress girls with your BASH skills. Be the coolest kid on the block. Get invited to all the parties. Get everyone to buy you beer, etc...
Here are some cool tricks to use in BASH.
I have scrounged 3500-odd DX7 synthesizer voice files from various sources, and many have similar names. For the DX7 emulator to access them all, they need to be in only one directory, ~/sysex/voice. and each filename must start with a unique 6-digit prefix. Here is how to apply such a sequential, unique prefix to a bunch of files in a directory:
