| Bash

October 25th, 2021 07:18:53 PM

#!/bin/bash #Leif Messinger lsm0147 FILES cred="Leif Messinger lsm0147" for bruh; do if [[ $bruh =~ \.cpp|\.c|\.java|\.js ]]; then comment="//$cred" else #Basically everything else gets a pound sign comment #Pound signs are standard across linux. bash, sed, gawk, python etc #Speaking of which, I need to escape it because of that. comment="\#$cred" fi if [ -s $bruh ]; then #If the file has a shebang if egrep -q '^#!/' $bruh; then sed -i "/^\#!\//a$comment" $bruh else sed -i "1i$comment" $bruh fi else echo "$comment" > $bruh fi done

Featured Posts