• Nov 14, 2021 •LeifMessinger
0 likes • 0 views
#!/bin/bash #Takes all the c and h files in the current directory and prints them #Yup, it's that easy for file in *.h *.hpp *.c *.cpp; do #If it exists if [ -f "$file" ]; then echo "//===============$file===============" cat $file fi done
• Sep 9, 2023 •LeifMessinger
0 likes • 3 views
#!/bin/bash #Changes the remote url from https to ssh. #Only works for github, because I'd have to store a dictionary of every https to ssh url otherwise. #Made using Bing Chat # Get the remote URL from the console REPO_URL=$(git config --get remote.origin.url) # Check that REPO_URL contains https://github.com if [[ $REPO_URL == *"https://github.com"* ]]; then # Replace https with ssh in the URL REPO_URL=${REPO_URL/https:\/\/github.com\//[email protected]:} # Change the remote URL to the SSH version git remote set-url origin "$REPO_URL" else echo "Error: REPO_URL does not contain https://github.com" >&2 exit 1 fi
• Nov 17, 2021 •LeifMessinger
0 likes • 6 views
#!/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" != "" ]; do echo "#include<$1>" | g++ -x c++ -E - shift done
• Apr 21, 2021 •LeifMessinger
#diskRipper.sh by Leif Messinger #For use on debian, where your cds aren't immediately mounted wall "CD inserted boss" set -x #echo on cdDrivePath=$(ls -l /dev/cdrom | awk '{print $NF}') #CD could have no label, so that's why I need awk cdLabel=$(lsblk -n "/dev/$cdDrivePath" -o label) if [[ ! -z "$cdLabel" ]]; then #CD has label folderName=$cdLabel echo "The cd label is ${folderName}" if mkdir ./cds/"${folderName}"; then #Folder didn't exist before sudo mount /dev/cdrom ./.cdmountpoint sudo cp -r ./.cdmountpoint/* "./cds/${folderName}" sudo chmod -R 777 "./cds/${folderName}" sudo umount ./.cdmountpoint eject wall "CD done and ejecting" else wall "Already read that cd, skipped" fi else wall "CD had no label, skipped" fi
• Oct 30, 2020 •LeifMessinger
0 likes • 2 views
#!/bin/bash #getDependencies.sh by Leif Messinger grep -Po '#include\s*"\K.+(?=")' | while read -r line ; do echo -n " $line" ./getDependencies.sh < $line done
• Aug 7, 2023 •C S
# Three ways of checking if a file exists in a shell script FILE=/etc/resolv.conf if test -f "$FILE"; then echo "$FILE exists." fi if [ -f "$FILE" ]; then echo "$FILE exists." fi if [[ -f "$FILE" ]]; then echo "$FILE exists." fi