Skip to content

Instantly share code, notes, and snippets.

@dbechrd
Created February 28, 2021 11:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbechrd/e37f1a6915db18a924da969b87f480ae to your computer and use it in GitHub Desktop.
Save dbechrd/e37f1a6915db18a924da969b87f480ae to your computer and use it in GitHub Desktop.
#!/bin/sh
###############################################################################
# Copyright 2021 - Dan Bechard
# Deletes a random line of code from a random source file to cause chaos. >:)
###############################################################################
# Directory where source files are kept
sourcedir="src"
# Directory depth to search
depth=1
# Pick a random file in the src directory
filename="$(find "$sourcedir" -maxdepth "$depth" -type f -regex '.*\.\(c\|h\|cpp\|hpp\)' | shuf -n 1)"
# Pick a random line number in the file
linenum="$(shuf -i 1-$(wc -l < "$filename") -n 1)"
echo "$filename:$linenum"
# [Print] Delete that line number from the file and print result
sed -e $(printf '%dd;' "$linenum") "$filename"
# [MODIFY] Delete that line number from the file, actually
#sed -i -e $(printf '%dd;' "$linenum") "$filename"
@JonathanCline
Copy link

fucking evil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment