Sections

The Basics awk is treat each line as a table, by default space are separators of columns. General syntax is awk 'search {action}' file_to_parse. # Give the value higher than 75000 in column $4 df | awk '$4 > 75000' # Print the all line when column $4 is higher than 75000 df | awk '$4 > 75000 {print $0}' But if you...

The Basics sed -e 'โ€ฆ' -e 'โ€ฆ' # Several execution sed -i # Replace in place sed -r # Play with REGEX # The most usefull sed -e '/^[ ]*#/d' -e '/^$/d' <fich.> # openfile without empty or commented lines sed 's/ -/\n -/g' # replace all "-" with new lines sed 's/my_match.*/ /g' # remove from the match till end of line sed...

Interesting example from justfile documentation: where it create mktemp and set it in variable then by concatenation you get a full path to the tar.gz. Then the Recipe โ€œpublishโ€ create the artifact again and push it to a server. tmpdir := `mktemp` # Create a tmp file version := "0.2.7" tardir := tmpdir /...

Shell Variable $$var $$( python -c โ€˜import sys; print(sys.implementation.name)โ€™ ) Make Variable T ?= foo # give a default value T := $(shell whoami) # execute shell immediately to put in the var PHONY to execute several makefile Example 1 SUBDIRS = foo bar baz ## dir is a Shell variables ## SUBDIR and MAKE are...

Pypi Repo for airgap env Letโ€™s take as an example py dependencies for Netbox # Tools needed dnf install -y python3.11 pip install --upgrade pip setuptool python-pypi-mirror twine # init mirror python3.11 -m venv mirror mkdir download # Get list of Py packages needed curl...

Package with pip3 pip3 freeze netaddr > requirements.txt pip3 download -r requirements.txt -d wheel mv requirements.txt wheel tar -zcf wheelhouse.tar.gz wheel tar -zxf wheelhouse.tar.gz pip3 install -r wheel/requirements.txt --no-index --find-links wheel Package with Poetry curl -sSL https://install.python-poetry.org...

# Import values with details connexion . .\values.ps1 $scriptFilePath ="$MyPath\Install\MysqlBase\Script.sql" # Load the required DLL file (depend on your connector) [void][System.Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\MySQL\MySQL Connector Net 8.0.23\Assemblies\v4.5.2\MySql.Data.dll") # Load in var...

POO # Convert your json in object and put it in variable $a = Get-Content 'D:\temp\mytest.json' -raw | ConvertFrom-Json $a.update | % {if($_.name -eq 'test1'){$_.version=3.0}} $a | ConvertTo-Json -depth 32| set-content 'D:\temp\mytestBis.json' Example updating a XML #The file we want to change $xmlFilePath =...