r_bash – Telegram
HELP ME

#!/bin/bash

# Decrypt function
function decrypt {
MzSaas7k=$(echo $hash | sed 's/988sn1/83unasa/g')
Mzns7293sk=$(echo $MzSaas7k | sed 's/4d298d/9999/g')
MzSaas7k=$(echo $Mzns7293sk | sed 's/3i8dqos82/873h4d/g')
Mzns7293sk=$(echo $MzSaas7k | sed 's/4n9Ls/20X/g')
MzSaas7k=$(echo $Mzns7293sk | sed 's/912oijs01/i7gg/g')
Mzns7293sk=$(echo $MzSaas7k | sed 's/k32jx0aa/n391s/g')
MzSaas7k=$(echo $Mzns7293sk | sed 's/nI72n/YzF1/g')
Mzns7293sk=$(echo $MzSaas7k | sed 's/82ns71n/2d49/g')
MzSaas7k=$(echo $Mzns7293sk | sed 's/JGcms1a/zIm12/g')
Mzns7293sk=$(echo $MzSaas7k | sed 's/MS9/4SIs/g')
MzSaas7k=$(echo $Mzns7293sk | sed 's/Ymxj00Ims/Uso18/g')
Mzns7293sk=$(echo $MzSaas7k | sed 's/sSi8Lm/Mit/g')
MzSaas7k=$(echo $Mzns7293sk | sed 's/9su2n/43n92ka/g')
Mzns7293sk=$(echo $MzSaas7k | sed 's/ggf3iunds/dn3i8/g')
MzSaas7k=$(echo $Mzns7293sk | sed 's/uBz/TT0K/g')

flag=$(echo $MzSaas7k | base64 -d | openssl enc -aes-128-cbc -a -d -salt -pass pass:$salt)
}

# Variables
var="9M"
salt=""
hash="VTJGc2RHVmtYMTl2ZnYyNTdUeERVRnBtQWVGNmFWWVUySG1wTXNmRi9rQT0K"

# Base64 Encoding Example:
# $ echo "Some Text" | base64

# <- For-Loop here

# Check if $salt is empty
if [ ! -z "$salt" ]
then
decrypt
echo $flag
else
exit 1
fi



Create a "For" loop that encodes the variable "var" 28 times in "base64". The number of characters in the 28th hash is the value that must be assigned to the "salt" variable.

I have tried every single line of code that i know and still didn't get the right answer

https://redd.it/1p1zx87
@r_bash
Concurrency and Strict Mode

I added a chapter about Bash and Concurrency in my small Bash Strict Mode Guide:

https://github.com/guettli/bash-strict-mode?tab=readme-ov-file#general-bash-hints-concurrency

Feedback is welcome:


## General Bash Hints: Concurrency

If you want to execute two tasks concurrently, you can do it like this:

# Bash Strict Mode: https://github.com/guettli/bash-strict-mode
trap 'echo -e "\n🤷 🚨 🔥 Warning: A command has failed. Exiting the noscript. Line was ($0:$LINENO): $(sed -n "${LINENO}p" "$0" 2>/dev/null || true) 🔥 🚨 🤷 "; exit 3' ERR
set -Eeuo pipefail

{
echo task 1
sleep 1
} & task1_pid=$!

{
echo task 2
sleep 2
} & task2_pid=$!

# Wait each PID on its own line so you get each child's exit status.
wait "$task1_pid"
wait "$task2_pid"

echo end


Why wait each PID separately?

- You must wait to reap background children and avoid zombies.
- wait pid1 pid2 will wait for both PIDs, but its exit status is the exit status of the last PID
waited for. This means an earlier background job can fail yet the combined wait can still return
success if the last job succeeds — not what you want if you need to detect failures reliably.



https://redd.it/1p20iz7
@r_bash
Forgot that I added this. Love past me!
https://redd.it/1p38uu0
@r_bash
how do you manage your .bashrc and ,bashprofile

Hi


I'm looking at puppet and setting up standard alias and other things

I don't really want to take over \~/.bashrc or \~/.bash\
profile



I was thinking maybe the way to do this was to add at the bottom

. (or source) \~/.bashrc-puppet

and

. (or source) \~/.bashrc-local


so that what files or other things can add / remove lines to \~/.bashrc puppet can manage the .bashrc-puppet and local mods can go into .bashrc-local

and the same for the bash_profile






https://redd.it/1p4e3yp
@r_bash
Crypto backup tool

It uses zip and gnupg.

**Features**:

* double encrypt: by zip and by gnupg
* generate hash'es from given password with 1000 iterations, it's prevent easy brute force
* once setup: just use symlinks in backup directory
* ready for cron: just use env variable
* simple for code review and modify

[https://github.com/LazyMiB/Crypto-Backup-Tool](https://github.com/LazyMiB/Crypto-Backup-Tool)

https://redd.it/1p4fjhj
@r_bash
Beginner-friendly Bash project: Real-time CPU Usage Monitor Script (with alerts + logs)

Sharing a small Bash automation project I built for practice. This noscript monitors CPU usage in real-time using top \+ awk, sends an alert when the CPU crosses a threshold, and logs usage automatically.

Step-by-step explanation: https://youtu.be/nVU1JIWGnmI
Complete source code at https://github.com/Abhilashchauhan1994/bash\_noscripts/blob/main/cpu\_usage.sh

https://redd.it/1p4nobz
@r_bash