Skip to content

Instantly share code, notes, and snippets.

@nullstream
nullstream / awk-primer.sh
Created April 14, 2018 13:59
2 Minute Guide to awk.
awk '{ print $1 }' file.txt # Print column one from each line in file.txt
cat file.txt | awk '{print $2}' # Print column two from each line of piped input.
awk '{ print $3 $5 $NF }' file.txt # Print columns 3 & 5 and number of colums/fields on each line of file.txt.
awk 'BEGIN{ s=0 } { s+= $3 } END{ print s }' file.txt # Sum up column 3 and print at the end of input (BEGIN=pre input, END=EOF)
awk 'BEGIN{n=0}{n+=$NF}END{print n/$NR}' file.txt # Print the average number of of fields per record in file.txt
awk '/foo/' file.txt # Print lines that contain 'foo' in file.txt
awk '/foo/{print $0}' file.txt # Print all records on lines that contain 'foo' in file.txt
awk '/foo/{print $2}' file.txt # Print column 2 from all lines that contain 'foo' in file.txt
awk '$2=="foo"{print $1}' file.txt # Print column 1 fro
#!/bin/sh
# Ensure wxallowed in /usr/local in fstab
# Inventory should have for each obsd host: ansible_python_interpreter=/usr/local/bin/python become_method=doas
#
# ./bootstrap-openbsd-new.sh hostname user
ANSIBLE_USER=control
INVENTORY=hosts
# Add host key to known_hosts
ssh-keyscan -H $1 >> ~/.ssh/known_hosts
@nullstream
nullstream / upgrade-obsd-63.yml
Created April 3, 2018 02:35
Ansible upgrade prep playbook OpenBSD 6.3
---
- hosts: openbsd
become: yes
become_method: doas
gather_facts: no
tasks:
- name: "Download bsd.rd"
#shell: "cd /; ftp http://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.3/`uname -m`/bsd.rd"
shell: "cd /; ftp https://cdn.openbsd.org/pub/OpenBSD/6.3/`uname -m`/bsd.rd"
- name: "Download SHA256.sig"
echo OFF
ipconfig /flushdns
net stop COMSysApp
taskkill /F /IM iexplore.exe
taskkill /F /IM dllhost.exe
taskkill /F /IM taskhost.exe
taskkill /F /IM taskhostex.exe
del /Q %LocalAppData%\Microsoft\Windows\WebCache\*.*
net start COMSysApp
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351