Loading...
More Shell Posts
#!/bin/bash#cpcmd.sh [file1 [file2...]]#Prints out the commands needed to copy the file to your local machine#This will work on any server that also has the same hostname as in your hosts file.#I should update this to detect if a file is a directory, and enable recursion for those commands. If you do it now, it will probably just warn you.if [ -n "$1" ]; thenwhile [ -n "$1" ]; doprintf "scp \"$(whoami)@$(hostname):"printf `readlink -f $1`printf "\" .\n"shiftdoneelseecho "scp \"$(whoami)@$(hostname):$PWD/*\" ."fi#-----------EDIT:#On the UNT cell machines, you have to do this script instead#if [ -n "$1" ]; then# while [ -n "$1" ]; do# printf "scp $(whoami)@$(hostname).eng.unt.edu:"# printf `readlink -f $1`# printf " .\n"# shift# done#else# echo "scp $(whoami)@$(hostname).eng.unt.edu:$PWD/* ."#fi
#!/bin/shBAT_LOW=15BAT_CRITICAL=5if [ "$1" = "--help" ]thenprintf "Usage:\tbattery_check.sh warning%% hibernate%%Description:\tA script for notifying the user via dunst and logging when\tthe battery is low and the system is going to hibernate.\tCan be supplied arguments for the battery low warning and\thibernation percentage thresholds as the first and second arguments.\t Default behavior is to warn at 15% and hibernate at 5%."exitfiif [[ -n "$1" && -n "$2" && $1 -gt $2 ]]thenBAT_LOW=$1BAT_CRITICAL=$2fiacpi -b | awk -F'[,:%]' '{print $2, $3}' | {read -r status capacityecho Low threshold: $BAT_LOW, Hibernate threshold: $BAT_CRITICALecho Status: $status, Capacity: $capacityif [ "$status" = Discharging -a "$capacity" -le $BAT_CRITICAL ]; thenecho Battery critical threshold.dunstify -u critical "Critical battery threshold, hibernating..."logger "Critical battery threshold, hibernating..."sleep .5systemctl hibernateexitfiif [ "$status" = Discharging -a "$capacity" -le $BAT_LOW ]; thenecho Battery low threshold.dunstify -u critical 'Battery low! System will hibernate at 5%.'logger 'Battery low! System will hibernate at 5%.'sleep .5light -S 15exitfi}
CLIENT_VPN_ID="cvpn-endpoint-xxxxxxxxxxxx"for region in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); doecho "Searching in region: $region"aws ec2 describe-client-vpn-endpoints --region $region --query "ClientVpnEndpoints[?ClientVpnEndpointId=='$CLIENT_VPN_ID']" --output tabledone
#Leif Messinger#For when you want to search a lot of words in a file fast#Arg 1 is the argument the list of words you want to search#Arg 2 is the file you want to search#-z means that it looks at the file as a whole, just treating newlines a characters.#-r is regex. Needed for $, even tho the documentation says you don't need it. They are liars.#First command replaces all . with \. and all - with \-#Second command takes all newlines and replaces them with )|(#Third command takes the trailing |( and deletes it#Forth command puts a /( at the start#Fith command puts /!d at the end. This tells it to not delete any lines that match the pattern.#The second sed takes the output of the first sed as a command that searches any of the combined words#-f - takes a command from the inputsed -z -r -e 's/\./\\\./g ; s/\-/\\\-/g' -e 's/\n/\)\|\(/g' -e 's/\|\($//' -e 'i/\(' -e 'a/!d' $1 | sed -r -f - $2
# Update all npm packages under the scope defined by the PREFIX variable ("foo").PREFIX="foo"; npm ls | grep "$PREFIX" | awk -F/ '{print $NF}' | sed 's/@.*//' | xargs -I package npm update @"$PREFIX"/package
#!/bin/bash#Takes command line arguments and pulls the header files.#Good for checking if the function you want is in the header or not.#cppToStdout.sh "time.h"while [ "$1" != "" ]; doecho "#include<$1>" | g++ -x c++ -E -shiftdone