Summary | How to control (or Understand) your GIST page's files list order. |
Notice | not official documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to just buffer each line (rather than the entire input stream) when using awk / gawk to read data from a pipe. | |
awk '{ print $0 ; system("") }' # compatible with POSIX complient systems | |
gawk '{ print $0 ; system("") }' # gawk is smart and will not actually start a sub-shell | |
# fflush - is going to offer something similar (although you can speicify which kind of output you would like to flush). | |
# remove first column (using white space) keep all other columns | |
awk '{sub(/^[^[:space:]]+[[:space:]]+/, ""); print}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is used to clear the arp cache on macOS - it may even work on other operating systems | |
# (C)2005 Henri Shustak | |
# Released Under MIT Licence : http://mit-license.org | |
# check we are running as root | |
currentUser=`whoami` | |
if [ $currentUser != "root" ] ; then | |
echo This script must be run with super user privileges |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# macOS 10.15 and later | |
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# simple script for macOS systems. It will switch to the location specified below if it is exists. | |
switch_to_location="Automatic" | |
current_location=`scselect | grep "*" | grep -v "Defined sets include: " | awk -F "(" '{print $2}' | awk -F ")" '{print $1}'` | |
if [ "{$current_location}" != "{$switch_to_location}" ] ; then | |
scselect "${switch_to_location}" | |
exit $? | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some programs will automatically save changes when closing files - Plan is to make a repository with a bunch of defaults which I use. For now it is a GitHub Gist. | |
Programs which seem to do this are listed below : | |
- Texttastic : https://www.textasticapp.com | |
More default settings now availble in a repository : | |
https://github.com/henri/handy-settings-macOS/ | |
---- CLI Details ---- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# select lines which start with upper case or lower case letter at the start of the line | |
grep -E "^[a-z]|[A-Z]" | |
# enable line buffering (useful for dealing with pipes and real time loops) | |
grep --line-buffered "search term" | |
# enable highlighting for a match but do not filter output (all of these examples will have a similar effect) | |
ack --passthru 'hightlight-match-string' | |
grep "^\|highlight-match-string" --color="always" | |
grep "^\|highlight-match-string" --color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (C)2020 Henri Shustak | |
# Relased Under MIT LICENCE | |
# https://mit-license.org/ | |
# benchmark bash function | |
# requires gdate to be installed (part of coreutils) | |
# This system is very basic and has some serious limitiations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# find files within folder with creation time falling between 6PM and 9AM (change as required). | |
for f in /myfolder/* ; do | |
var=$(date -r "$f" '+%H') | |
if [ $var -gt 18 ] || [ $var -lt 9 ] ; then | |
ls -l "$f" | |
fi | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# netstat (more similar to GNU/LINUX) on macOS | |
lsof -i -P | grep -i "listen" --line-buffered |