Skip to content

Instantly share code, notes, and snippets.

View bsnux's full-sized avatar
💭
👨‍💻

Arturo Fernandez bsnux

💭
👨‍💻
View GitHub Profile
#!/bin/bash
# Print only lines matching expression
awk -F: '/ssh/ { print } ' /etc/group
# Print only if field 4 matchs expression
awk -F: 'match($4,/ssh/) { print } ' /etc/group
# Print field 1 only if field 4 matchs expression
awk -F: 'match($4,/ssh/) { print $1 } ' /etc/group
@bsnux
bsnux / simple-cheatsheet.sh
Created August 12, 2020 23:22
Simple and quick bash scripting reference
#!/bin/bash
#----------
# simple-cheatsheet.sh
#
# source: https://devhints.io/bash
#
#----------
# Variables
NAME="John"
@bsnux
bsnux / ansible-cookie-cutter.sh
Last active October 1, 2020 21:07
Ansible cookie cutter
@bsnux
bsnux / get-public-ip.sh
Created July 23, 2020 16:34
Getting public IP from Linux box
dig +short myip.opendns.com @resolver1.opendns.com
@bsnux
bsnux / deletePipelineOldBuilds.groovy
Created July 14, 2020 17:00
Delete old Jenkins pipeline job builds
import java.util.ArrayList
def MULTIBRANCH_JOBNAME = "project"
def BRANCH_NAME = "develop"
def MAX_TO_KEEP = 10
def hi = hudson.model.Hudson.instance
def item = hi.getItemByFullName(MULTIBRANCH_JOBNAME)
def jobs = item.getAllJobs()
@bsnux
bsnux / help-template.sh
Created July 8, 2020 21:00
Simple template for shell scripts
#!/bin/bash
# help-template.sh
#
# Simple template for shell scripts
#
Help=$(cat <<-"HELP"
my-script — does one thing well
Usage:
my-script <input> <output>
@bsnux
bsnux / list-spaces-tabs.vim
Created June 1, 2020 23:23
Listing spaces and tabs in Vim
set listchars=space:_,tab:>~ list
@bsnux
bsnux / perl-compiler.sh
Created May 13, 2020 16:33
Generates a binary from a Perl file
#!/bin/bash
#--------------------------------------------------------------
# perl-compile.sh
#
# Generates a binary file for Linux from a Perl file
#
# Usage: perl-compile.sh myfile.pl
#--------------------------------------------------------------
set -e
@bsnux
bsnux / Dockerfile.shellscript
Last active May 5, 2020 18:11
Simple Dockerfile base image for delivering shell scripts with no dependencies
FROM alpine:3.7
LABEL desc="Simple image for delivering shell script with no dependencies"
LABEL author="bsnux"
LABEL tag="1.0"
ADD your-script-here.sh /opt/your-script-here.sh
RUN apk update \
&& apk add \