Loading...
More Shell Posts
awk '\{ for (i=1; i<=NF; i++) { ++D[$i]; } }\END { for (i in D) { print i, D[i] } }\' words.txt | sort -nr -k 2
## Austin Leath# checks for /Desktop symlink. Creates the symlink if it doesnt already exist##Fetch the target user if desired, otherwise use the currently logged in user.if [ "$4" != "" ]; thenTARGET_USER=$4elseTARGET_USER=$3fiif [ "$5" != "" ]; thenDIRECTORY_NAME=$5elseTARGET_USER="$3 Desktop"fi# FunctionsCHECK_SYMLINK() {if test -f "/Desktop"; thenecho "/Desktop exists"elseecho "/Desktop does not exist"fi}CHECK_SYNTHETIC_CONF() {if test -f "/etc/synthetic.conf"; thenecho "/etc/synthetic.conf exists"elseecho "/etc/synthetic.conf does not exist"fi}CREATE_SYMLINK() {if [[ $(CHECK_SYNTHETIC_CONF) != "/etc/synthetic.conf exists" ]]; thenecho "/etc/synthetic.conf does not exist. creating.."touch /etc/synthetic.confchown -R root:wheel /etc/synthetic.conffiif grep -q "$DIRECTORY_NAME" /etc/synthetic.conf; thenecho "$DIRECTORY_NAME already exists"exit 1elseecho "$DIRECTORY_NAME\t/Users/$TARGET_USER/Desktop" >> /etc/synthetic.conffiecho "/Desktop symbolic link created"}if [[ $(CHECK_SYMLINK) != "/Desktop exists" ]]; thenCREATE_SYMLINKfiexit 0
#!/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
#!/bin/bash# Recursively find all .svelte files in the current directory and its subdirectoriesfind . -type f -name "*.svelte" -o -name "*.html" -o -name "*.htm" | while read file; do# Replace all h1 tags with the specified formatsed -i 's/<h1>\(.*\)<\/h1>/<h1 id="\1">\1<\/h1>/g' "$file"# Replace all h2 tags with the specified formatsed -i 's/<h2>\(.*\)<\/h2>/<h2 id="\1">\1<\/h2>/g' "$file"# Remove whitespace from the id attribute valuefor i in {0..10} ; dosed -i 's/\(id="[^"]*\)\W\([^"]*"\)/\1\2/g' "$file"donedone
#!/bin/bashgit statusecho "Do you want to add all changed files?"select yn in "Yes" "No"; docase $yn inYes ) break;;No ) exit 1;;esacdonegit add -ugit statusecho "Does this look right?"select yn in "Yes" "No"; docase $yn inYes ) break;;No ) exit 2;;esacdonegit commitecho "Do you want to push?"select yn in "Yes" "No"; docase $yn inYes ) break;;No ) exit 2;;esacdonegit push
#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