Jeffery B.'s Blog
  • Home
  • Ansible
  • Openshift
  • Author
Subscribe
Tagged

bash

A collection of 4 posts

bash

AWK: read the next line

getline, the function reads the next line and moves the script to it. I wanted to get the current git version number from https://git-scm.com/downloads, and using getline came very handy by running something like this: curl --silent https://git-scm.com/downloads | awk '/span class="version&

  • Jeffery Bagirimvano
Jeffery Bagirimvano Dec 20, 2020 • 1 min read
bash

BASH: Provide a default value that the user can change

I wanted to be able to provide a default value that the user can change in a bash script and found this... read -p "Name to deploy as: " -e -i "gitlab-runner" APP echo ${APP} Note that you need -e for -i to work as intended... And

  • Jeffery Bagirimvano
Jeffery Bagirimvano Oct 29, 2020 • 1 min read
bash

AWK - Display all fields except the last

awk 'BEGIN{FS=OFS="-"}{NF--; print}' It's come up a few times where I wanted to get all fields, except for the last one, and I always had to google it, which would take me about 15 min or so to find a

  • Jeffery Bagirimvano
Jeffery Bagirimvano Aug 25, 2020 • 1 min read
bash

How do I check if a port is open from a shell script

Sometime I find myself needing to check if a port is open, on a system or container, that doesn't have the usual programs such as, nc or netstat. Luckily, bash have a built in way of checking if a port is open: </dev/tcp/localhost/31339 &

  • Jeffery Bagirimvano
Jeffery Bagirimvano Apr 6, 2020 • 1 min read
Jeffery B.'s Blog © 2025