Tag command-line
Toggling Your Bluetooth Connection using bluetoothctl
on the Command-Line (1 mins read).
How to script bluetoothctl
to toggle your connection to a Bluetooth device.
A great addition for those scripting with curl!
Splitting an X509 PEM-Encoded Certificate Bundle into Multiple Files (1 mins read).
Splitting a certificate bundle into separate files using split
or awk
.
How to Use curl
to Send Requests to Domains Without Editing Your /etc/hosts
File (1 mins read).
Using curl
's --resolve
flag to perform custom lookup for hosts.
Triggering an AWS Lambda from the Command-Line (1 mins read).
How to invoke an AWS Lambda function from the Command-Line.
Generating HMAC Signatures on the Command Line with OpenSSL (1 mins read).
How to generate HMAC signatures for a given string, using openssl
.
Creating Signed JWTs (JWS) with Node.JS (1 mins read).
How to use the jsonwebtoken library to create a Signed JSON Web Token (JWS) with Node.JS.
I used to write a lot of shell scripts before realising that what I was trying to do was treat shell scripting as a "full" scripting language (I won't define here what I mean by "full").
Its not - reach for a higher level scripting language like Ruby or Python when things are getting more complicated, and allow shell scripts to glue things together, or be for quick tasks maybe a few lines long.
When you do write them, this advice is great but it's definitely worth gaining understanding of when you should and shouldn't use them.
Parsing a Unix Epoch With Bash/Ruby on the Command-Line (1 mins read).
How to convert a Unix Epoch to a human-readable date format.
Very interesting to see that there's even more to the command than expected - and some great new features coming soon.
Pretty Printing XML on the Command-Line (1 mins read).
How to use xmllint
to pretty-print XML/HTML files.
List What Files Changed in a Git Commit (1 mins read).
How to list what files changed in a given commit.
Using the OpenSSL Command-Line to Verify an SSL/TLS Connection (2 mins read).
How to use the openssl
command-line to verify whether certs are valid.
Pretty Printing YAML with the Ruby Command-Line (1 mins read).
Using Ruby's YAML
library to pretty-print YAML files from the command-line.
This is my go-to for tidying up disk space issues when working with Docker
Piping Data When Not Running a Command with sudo
(1 mins read).
How to (more) safely pipe stdin
to an elevated command with sudo tee
.
Minifying JSON with Python (1 mins read).
How to take a pretty-printed JSON string and replace it with a minifed JSON string using Python.
Minifying JSON with Ruby (1 mins read).
How to take a pretty-printed JSON string and replace it with a minifed JSON string using Ruby.
This is a great resource to highlight the difficulty of creating temporary files safely - something I've tried to share before but without these great examples.
Its especially bad if using a shared CI/CD server and putting downloaded files into /tmp as you don't know whether it'll be clobbered / stolen by others on the instance
This is a great article about how to be safer when writing shell scripts. I am a huge proponent of not using them where possible, and instead moving them to another scripting language (Ruby, Python, Node) which you can test, and use a shared standard library.
Adding Newlines to all Files in Git (3 mins read).
Adding newlines at the end of all Git-tracked files.
Easily Parsing Failed Cucumber Scenarios from the JSON Report (2 mins read).
How to parse a Cucumber JSON report to display the failed scenarios and their causes.
This is a great post - I thoroughly recommend learning how to use common commandline tools such as awk
, grep
, sed
, but also adopting a scripting language for more complicated stuff. I don't mean Bash, or another shell scripting language, but something like Node, Python or Ruby, as it'll give you the opportunity for a greater standard library, as well as tonnes of packages built by others.
Pretty Printing JSON Files Inline on the Command Line (2 mins read).
How to rewrite multiple JSON files inline on the Command Line.
Pretty Printing JSON Web Tokens (JWTs) on the Command Line using OpenSSL (3 mins read).
How to easily introspect a JWT on the command line using OpenSSL and optionally Python for real pretty-printing.
In every programming language, there is a linting tool that can help pick up on some common style issues. ShellCheck isn't one of those - it's so much more!
I've been using it for many years now, and since it came into my life it's honestly changed the way I use shell scripts. There have been so many pitfalls that I've avoided falling into since learning about them (and adding ShellCheck to my Vim linting setup.
This is a great read from Vidar, the ShellCheck author, about a case where it could've caught issues that caused the deletion of a production database!
URL Decoding with Ruby on the Command Line (1 mins read).
How to use Ruby's standard library to decode URLs with a handy one-liner.
Viewing X.509 DER Certificate Fingerprints with OpenSSL (1 mins read).
How to view an X.509 DER certificate's fingerprint using openssl
commands.
Viewing X.509 PEM Certificate Fingerprints with OpenSSL (1 mins read).
How to view an X.509 PEM certificate's fingerprint using openssl
commands.
Verifying Signed JWTs (JWS) with Node.JS (3 mins read).
How to use the jsonwebtoken and node-jose libraries to verify the signature of a Signed JSON Web Token (JWS) with Node.JS.
Setting your default AWS profile for the AWS CLI and SDKs (2 mins read).
Setting the default AWS profile when working with multiple profiles and the AWS CLI / SDKs.
Viewing X.509 DER Certificate Details with OpenSSL (2 mins read).
How to convert an X.509 DER file to a human-readable format using openssl
commands.
Viewing X.509 PEM Certificate Details with OpenSSL (2 mins read).
How to convert an X.509 PEM file to a human-readable format using openssl
commands.
Safely Force Pushing with Git using --force-with-lease=ref
(6 mins read).
How git push --force-with-lease=ref
can save you from overriding others' changes on shared Git branches.
My editorial workflow for blog posts (8 mins read).
Taking you through the journey I go on when writing blog posts, from ideation to publishing the post.
Viewing Git history of a file in git log
while ignoring file renames (5 mins read).
How to track changes to files in Git without pesky file renames getting in the way, using git log --follow
.