Skip to content

Instantly share code, notes, and snippets.

@laughingclouds
Last active October 20, 2021 21:18
Show Gist options
  • Save laughingclouds/45624204d8b4a6517e613f9e545ca9f9 to your computer and use it in GitHub Desktop.
Save laughingclouds/45624204d8b4a6517e613f9e545ca9f9 to your computer and use it in GitHub Desktop.
Recursively remove all the files that don't have the specified extension.
find . -type f ! -name "*.c" ! -name "*.h" ! -name "*.json" ! -name "*.py" ! -name "*.sh" ! -name "*.md" -exec rm {} \;
# This (recursively) removes any files that don't end with the above extensions
# code to compile one whole project (directory)
# Won't work if
# you have multiple folders
# you execute this from outside the project directory
COMPILER_INPUT="$(find ./$1 -type f -name "*.c")";
gcc $COMPILER_INPUT -o "./$1/a.out";
# Better than the rest, a frickin' makefile!
# https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
CC=gcc
CFLAGS=-I.
DEPS = header_file.h
OBJ = file1.c file2.c and_so_on.c
%.o: %.c $(DEPS) # for compiling the object code
$(CC) -c -o $@ $< $(CFLAGS)
main: $(OBJ) # for the final main file
$(CC) -o $@ $^ $(CFLAGS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment