Skip to main content

List all AWS EC2 Instances in all regions

Jul 29, 2024AustinLeath
Loading...

More Shell Posts

credit.sh

Oct 26, 2021LeifMessinger

0 likes • 2 views

#!/bin/bash
#Leif Messinger lsm0147
#credit.sh 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

LeetCode #192: Word Frequency

Oct 15, 2022CodeCatch

0 likes • 87 views

awk '\
{ for (i=1; i<=NF; i++) { ++D[$i]; } }\
END { for (i in D) { print i, D[i] } }\
' words.txt | sort -nr -k 2

diskRipper.sh

Apr 21, 2021LeifMessinger

0 likes • 6 views

#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

getDependencies.sh

Oct 30, 2020LeifMessinger

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

codecatch.sh

Nov 14, 2021LeifMessinger

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

AWS CLI Locate ClientVPN

Sep 23, 2024AustinLeath

0 likes • 3 views

CLIENT_VPN_ID="cvpn-endpoint-xxxxxxxxxxxx"
for region in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do
echo "Searching in region: $region"
aws ec2 describe-client-vpn-endpoints --region $region --query "ClientVpnEndpoints[?ClientVpnEndpointId=='$CLIENT_VPN_ID']" --output table
done