Last active
May 6, 2025 15:47
-
-
Save MrChrisWeinert/ba55c3b9fe845ea30c164e11479f746f to your computer and use it in GitHub Desktop.
Random bash bits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #bin/bash | |
| #This will list out all the .md files that DON'T contain 'tags' | |
| for filename in `find ./ | grep 'md$'`; do grep -L tags $filename; done | |
| #WITH tags | |
| for filename in `find ./ | grep 'md$'`; do grep -l tags $filename; done | |
| #Find in all files: | |
| find ./ -exec grep 'Critical' /dev/null {} \; | tee ~/grepResults.txt | |
| #Update hostname | |
| hostnamectl set-hostname new-hostname | |
| #Progress Bar (untested) | |
| #!/bin/bash | |
| ### Reports | |
| file1="example.csv" | |
| #################### | |
| ### Progress Bar ### | |
| #################### | |
| progress_bar_setup() { | |
| total_lines=$(wc -l < "$1") | |
| progress=0 | |
| echo -n "[--------------------] 0% " | |
| } | |
| progress_bar() { | |
| let progress++ | |
| let filled_slots=progress*20/total_lines | |
| bar="" | |
| for ((i=0; i<$filled_slots; i++)); do | |
| bar="${bar}#" | |
| done | |
| for ((i=filled_slots; i<20; i++)); do | |
| bar="${bar}-" | |
| done | |
| let percentage=progress*100/total_lines | |
| echo -ne "\r[${bar}] ${percentage}% " | |
| } | |
| progress_bar_complete() { | |
| bar="####################" | |
| echo -ne "\r[${bar}] 100% " | |
| echo;echo | |
| } | |
| ################## | |
| ### While Loop ### | |
| ################## | |
| echo "Progress Bar Title::" | |
| progress_bar_setup $file1 | |
| cat $file1 | while read line; do | |
| # Task | |
| progress_bar | |
| done | |
| progress_bar_complete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment