If you are on a POSIX compliant machine (OSX or Linux) you can make use of Shell Scripts to do day-to-day donkey work. I use Shell Scripts for backups, cleaning out temporary folders, profiling and logging. Writing these scripts is pretty straightforward and if you are completely new to it I recommend getting a copy of Classic Shell Scripting.
Recently I came across a couple of shortcuts that have greatly reduced the time it takes to write a script in the vi editor.
Using :! from within vi you can run a shell command. This is great as you don’t need to exit vi to test your code. Let’s say for example your script is called myscript.sh. You can run your script from within the vi editor by using.
Furthermore you can make more changes in vi, save the file and then run the script again by using
This is a shortcut to the last command issued to the shell, allowing you to retest your shell script without even typing the filename.
Within vi the % variable refers to the file that you are currently editing. So to run the script you are editing from within vi you can also use:
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Rolling deployments with Kubernetes
How to deploy a new version of an image into a Kubernetes cluster
Getting started with Kubernetes
How to get started with using Kubernetes on a local machine using minikube
Listening to BBC Radio with mpv
The BBC publishes high quality 320 kbps HLS AAC streams that can be used to listen to radio from the command-line using mpv. Here are the URLs and some aliases to start listening quickly.