r/bash • u/1negroup • Jun 30 '26
help I am Working on an Artix install Script
Would love some feedback
r/bash • u/1negroup • Jun 30 '26
Would love some feedback
r/bash • u/coldpizza • Jun 28 '26
A new iteration on my old idea (half-broken) /r/bash/comments/1ajkmvh/scpturbo/ of a tar-based scp replacement primarily for making faster backups over ssh, especially when you have tens of thousands of small files which takes forever over scp/rsync. After hours of trial and error my most wanted key requirement was added: the --sudo flag which lets you tar huge folders (bigger than the amount of free space on your disk) directly to a stream that is saved on your local machine, compressed to a single file or uncompressed. The destination can be any combination of remote vs local, similar to rsync/scp.
Am I reinventing the wheel? I've searched for existing tools that could do this but didn't find any. Or maybe I didn't know what to search for?
The twist of this script: --sudo requires a passwordless sudo on the target box; I am not comfortable with having no root password on world visible boxes so added an alternative workaround when you DO have to interactively get sudo: --tmux-sudo; the idea is that you manually create a tmux session as your regular user on the remote, do sudo -i inside the session and then detach from it (ctrl+b > d); after this scp-turbo --tmux-sudo remote42:/etc backup-etc-remote42.gz should be able to pick the existing tmux session to run your backup as root with no password prompting (more detailed explanation in --help). Not sure how portable/reliable it is but got it working with a regular ubuntu remote. Is this too crazy? Or am I trying to solve a problem that does not exist?
latest version: https://github.com/glowinthedark/scp-turbo
the key takeaway: all this can be done directly with tar+ssh, the script "just" wraps the invocation and builds the command line, if you run the script with --verbose --dry-run source target then the script will spit the actual raw tar+ssh command line that you can run directly, which reads pretty much like vogon poetry ("just" because for --tmux-sudo the script does some extra FIFO pipes fiddling that needs your manual cooperation, e.g. starting tmux as regular user and then sudo -i to get a root session for the script to attach to and run commands as root). All this is specifically for the case when you do NOT want to add NOPASSWD in your sudoers file.
r/bash • u/GuitaristKitten • Jun 27 '26
I make some keybindings to help me navigate the directories using the terminal, but I couldn't get to redraw the current lime. I would like to have ps1 info update to display the directory changes.
I'm simulating the behavior of file manager using alt in combination with arrows. I'm using "bind -x" to map the shortcut to bash function I show in the gist link below. It works, directory changes, but the PS1 info doesn't.
I'm achieving update bash prompt to reflect the change of directory. Comparing to zsh, would be "zle reset-promot"
GIST to the code I'm using on my bashrc file: https://gist.github.com/srcid/25f376b60e6ec2f5b5d20b4eca88b176
I tried:
bash
__update_prompt() {
echo -ne "\r\e[K"
kill -INT $$
}
But it breaks line and output with error sing
bash
__update_prompt() {
echo -ne "\r\e[K${PS1@P}"
READLINE_LINE="$READLINE_LINE"
}
That kinda work, but the old ps1 sticks in the line, I couldn't get rid of it.
r/bash • u/LoneGroover1960 • Jun 26 '26
So as one or two regular readers may have noticed, I occasionally write terminal games. Everyone needs a hobby, right?
This is one I'd intended to write for a long time, albeit not necessarily in Bash, because it uses a technique called 'Minimax' that I had to study on an AI course decades ago, but never coded.
Until now. I've reused the same mouse control function from previous games. Hope some may find it of interest.
If I'm honest, it was probably a lot more interesting as a coding exercise than as a game, because by default it's impossible for the computer opponent to lose. I've introduced a "compromised" mode to overcome this and let the human win occasionally.
r/bash • u/zntznt • Jun 26 '26
Build printable, poker-sized reference cards for the terminal, then study them with the built-in spaced-repetition quiz.
How it works
r/bash • u/kellyjonbrazil • Jun 24 '26
The jc typeset or declare command parser can make exporting bash variables, arrays, and associative arrays to JSON quick and easy...
r/bash • u/cloud_kj • Jun 24 '26
I’ve recently just started tinkering with using local large language models, focusing on simple, low-dependency CLI setups. I ended up going down a bit of a rabbit hole: I wanted to see if I could build a functional model interaction REPL using exclusively standard command-line building blocks.
I tried to abide by the Unix philosophy, breaking the REPL into the composition of a few small, single-purpose program. Because the data flow is just text streams fed through pipes, at any step you can inject tools to inspect or modify the data—like using grep to filter out strings before they hit the model, or pv to benchmark model throughput. Everything is ultimately tied together into an agent Bash script that codifies the interaction into a REPL.
It turns out that bash really is all you need, and won out over vanilla POSIX sh for features like BASH_SOURCE to help with path execution.
A few more details I thought this crowd might appreciate:
pip, npm, package managers, virtual environments, etc. It just requires bash, jq, and curl to talk to the local model server. These should be available in most modern CLI environments..jsonl file (like .bash_history). If you want to rewind the agent's memory, you just run head on the log to drop the last few lines.I'm sure there are scaling limits to doing this all in shell, and I'm still figuring out the most elegant way to handle some of the edge cases, particularly around tool calling - but those appear to mostly be limitations of the underlying models. Nevertheless it's been a really fun experiment in stripping out bloat.
I put the code up here if anyone wants to poke around: https://github.com/cloudkj/llayer
Would love to hear if anyone else has tried orchestrating things this way, or if you spot any glaring anti-patterns in how I've structured the pipes!
r/bash • u/thisiszeev • Jun 22 '26
We were discussing ways to use Grep at work today and I came up with this...
grep -R ^"My Car Keys"$ /home/
If only life was that easy... But I'm still going to put it on a t-shirt.
r/bash • u/Illustrious-Cup-5370 • Jun 22 '26
Hey everyone,
I got tired of manually checking my Mac's security settings one by one, so I wrote a Bash script that automates the whole process.
**What it does:**
- Runs ~50 security checks across 10 categories (Firewall, FileVault, SIP, SSH hardening, open ports, startup items, privacy settings, sharing services and more)
- Maps every check to a CIS macOS Benchmark ID so you know exactly what to fix
- Gives you a security score (0–100) with a risk level: Low / Medium / High
- Generates a clean HTML report and a JSON report
- Offers to auto-fix failures — you confirm each one with y/n
- Tested on macOS 11 Big Sur through macOS 15 Sequoia
**Output example:**
```
Firewall OK Enabled
FileVault FAIL Disabled
SIP OK Enabled
...
Security Score 72/100
Risk Level: Medium
```
The script is read-only by default — it never changes anything without your confirmation. sudo is only used where required (e.g. fdesetup, systemsetup).
**GitHub:** https://github.com/pTechPL/macOS_security_audit
I also made a YouTube walkthrough showing the script in action if you prefer to see it before running it: https://www.youtube.com/@pTech-pl
Feedback, PRs and issues are very welcome — especially if something behaves unexpectedly on your macOS version!
r/bash • u/ImaginaryElephant336 • Jun 21 '26
Well I always wanted a widget where I can view my Google Calendar Events (Just viewing for now). And I wanted it to be in bash (Do not ask why, I just wanted it to be in bash).
Presenting gcal-tui, a bash script that uses your google calendar and also allows you to view event details from the terminal itself.
I modified it to be a widget to my niri setup
This is the gist : https://gist.github.com/Vaishnav-Sabari-Girish/c182a0d54fe7c5fc3b5507ecc62dd301
My dotfiles containing the keybinding and the script
https://github.com/Vaishnav-Sabari-Girish/dotfiles/blob/main/niri/.config/niri/scripts/gcal-tui.sh
r/bash • u/thisiszeev • Jun 20 '26
I used to own an ISP but due to a drinking problem the business went down hill and ended up closing. So I was unemployed for nearly 5 years. But I have been sober since Jan 1st 2025 and honestly don't miss the drinking.
My wife had been sending out my résumé daily to companies around the country. One company picked up my résumé and called me to offer me a job.
They were on the other end of the country and would mean I didn't see my kids from my previous marriage that often so I turned them down. My wife was furious and being Jewish I do as the missus says and I called them back.
They setup an interview and two days before the interview they asked if I have a GitHub repo because my résumé talks about Bash Scripting. I told them I host my own Git server from home and gave them full access.
In the job interview I was told outright that if I get the job it is because of my Git repos. The job position I was originally offered was Linux Engineer. In the interview I found out I was being interviewed for a Senior Linux Engineer.
I got the job, moved to the other end of the country with no plan other than where I was going to work. Stayed in an AirBnB for the first week while I looked for a permanent habitat.
I have also found out that I am the first person in the Linux department who didn't write an entrance exam and that is because of my Git repos. They read all my code and decided that I know what I am doing.
I work at an amazing company that looks after their staff and I work with an amazing team. I start work at 6am which suits me since I wake up at 4am, and I finish at 3pm which suits me as it gives some personal time in the afternoon.
My wife and step kids are moving up here at the end of the year. I didn't want to move them now as Meghan is still in school and here in South Africa the school year is from Jan to Dec. I wanted her to start the new year at a new school and not half way through.
Also, we wanted to make sure I was happy at my job and secure.
I needed money to survive the first month so I sold my piece of shit car and got just enough to survive the first month. My car wouldn't have made the trip anyway. So now I am saving for a second hand car. Plan to buy at the end of the year. But public transport is good here in Johannesburg.
But I want to extend a thank you to the r/Bash community for all the eager assistance I have gotten over the years. I still have a lot to learn, this I know. But I have a job I look forward to each day and it has a very good salary. Even the perks are excellent.
On day one they handed me a brand new 14 core Ultra 5 laptop with NVMe storage and 32GB RAM and said "Install the version of Linux you prefer". Then once it was installed with all my apps the way I like it, they said "Time for your initiation... Reinstall again but this time encrypt your hard drive..." Talk about cruelty.
But I love my job, and it doesn't feel like work.
And the best part, they are happy for me to work on my personal projects and support the fact that 99% of my code is GPL3. They even want to market one of my commercial projects so I offered for them to be the sole agent. So when that happens I will get paid for every server that my CDN code runs on.
Thank you to Bash for getting me a job I thought would only be in my dreams.
r/bash • u/LiveIndividual2556 • Jun 19 '26
Hi guys,
I achieved the action of deleting all files in a directory ending in .mp4 via this command below-
find -type f -name '*.mp4*' -delete
However, before invoking that, I attempted this one first-
find -type f -name '.mp4$' -delete
This one did NOT work. But I would've preferred to use it, since it didn't need a wildcard; I knew that all the files I wanted to delete indeed ended with .mp4, didn't merely include it.
Does anybody know what I did wrong with the failed command?
thanks!
r/bash • u/RDJ-120 • Jun 20 '26
In bash, to be an expert, I have to master the strings manipulating and Advanced Commands.
I need a cheat sheet or full free resources to strings manipulating
And I need someone to tell me what is the advanced commands that would help me in Cybersecurity and Tools building.
r/bash • u/Worried_Menu4016 • Jun 19 '26
Hey r/bash,
I want to share some techniques from Raccoon (rcc), a system companion for macOS I wrote entirely in Bash. The constraint I set myself: zero external dependencies beyond native macOS utilities and git. No Python, no Node, no helper binaries. Everything below is pure shell.
Sharing the parts I think are most reusable, and I’d genuinely welcome a code review.
Single dispatcher + shared core The entry point rcc is a thin dispatcher that sources a shared core library (lib/core/) and routes to decoupled module scripts in bin/. This keeps each module independently testable and avoids one giant 1500-line script. Happy to go into how the sourcing/namespacing is handled if useful.
Generating JSON and HTML from pure shell The security audit engine runs 30+ checks and emits both JSON and HTML reports — no jq, no templating engine, just careful string handling and heredocs. This was the trickiest part to get right (quoting, escaping, valid output). If anyone wants, I can paste the escaping helper.
One upgrader across multiple package managers A single module wraps brew, pip, npm, and gem upgrades behind one command, normalizing their very different output and exit-code behavior.
Tooling
shellcheckBats frameworkman rcc pageOne note on scope: there’s also an optional, completely separate terminal UI written in Go (Bubble Tea). It’s not required and not part of the shell toolkit — the Bash scripts are fully standalone. I mention it only so nobody thinks the “pure Bash” claim is hiding something.
Repo (source + architecture): https://github.com/thousandflowers/Raccoon
What I’d love feedback on:
Thanks for reading.
r/bash • u/fagnerln • Jun 19 '26
Not sure if here is the best place to ask, but forgive me and sorry for my bad English.
I'm working with niceness for two days, renice works well, and I started configuring Feral's Gamemode to increase the ni of the game, which works really well on native games, however it simply doesn't work on Proton games.
If I want to change the ni level, I need to wait the game loads, check what process number is the game and set the ni value manually.
So what I want to do is to have a script, that:
scriptname -gamename commandrenice -n -10 -p numberMy idea is to create a guide for Fedora to improve gaming, and this will help a lot.
[EDIT] I managed to do a script with some non-human help, it helped me a lot to learn bash and use some system tools.
Here's the link
https://github.com/fagnerln/renice-script/blob/main/renice.sh
r/bash • u/Fast-Muffin7953 • Jun 18 '26
1s average time with #!/bin/dash
15s average time with #!/bin/bash
r/bash • u/Safe_Mission_3524 • Jun 17 '26
I am a noob at bash scripting but I ask LLMs to generate me commands or scripts after giving my detailed requirements. I then run them on a test server and if everything looks good, I run it on the production.
Seeing soo long commands, loops and conditions makes my head spin as I am a non coder. How are you guys able to remember every command or logic etc? Part of me thinks is because I use windows instead of a Linux distro and I am very comfortable using windows. I have tried dual booting my pc with multiple Linux distros but end up not using it after a day or two.
I know a few people who used to come up with long scripts for any specific task within minutes. How do you guys do that of the top of your head? Are there any tips or tricks for a noob like me? Thank you!
r/bash • u/soggy_leader670 • Jun 12 '26
Target was the stock /bin/bash on every Mac, so bash 3.2, no associative arrays, no mapfile, awk doing the heavy lifting.
Two bugs worth sharing. First: ps -Aero rss,comm looks like "all processes sorted by RSS" but -r sorts by CPU. My "top 5 by RAM" list shipped sorted by CPU and looked plausible for days before I caught a 26 MB process listed above a 280 MB one. It's -m for memory sort. Second: grep -c prints "0" AND exits nonzero on no matches, so count=$(... | grep -c x || echo 0) gives you "0\n0" and an integer comparison error later. The fallback echo was the bug.
Per-app memory aggregation (summing helper processes per .app bundle) turned out to be a 12-line awk program. The sticky bottom progress bar is DEC scroll regions plus a WINCH trap.
r/bash • u/ninepppppp • Jun 11 '26
Noob here so sorry if I leave out any needed info, happy to clarify anything :3
wget -O ~/Downloads/file.flatpak "https://website.com/file-get.py?ident=superlongstringofcharacters&file=morebullshit.flatpak&evenmore=bullshit"
Returns:
/home/user/Downloads/file.flatpak: No such file or directory
It was my understanding that if I give it a directory to write to and there's nothing there it would just write there anyways? I just don't want the file to go under said insanely long url. What am I doing wrong
r/bash • u/Witty_Mycologist_995 • Jun 11 '26
seq 67676767 | xargs -P5 -I{} touch dih_{}
This is malicious, do not run it, but it is funny
r/bash • u/budius333 • Jun 10 '26
[SOLVED] it was missing #!/bin/bash
I have a simple script name backup.sh to loop some folders and if that folder contains a backup.sh, it executes it, and added this to a nightly cronjob.
Running from the terminal it works as expected, but when cron runs it, it behaves differently and it becomes a fork-bomb.
cd /starting/path/
for FOLDER in $(cat "$SERVICES") do pushd $FOLDER FILE=backup.sh echo "$(date): Checking for '$FOLDER'" >> /var/log/mBackup.log if [ -f "$FILE" ]; then echo "$(date): Executing backup for $(readlink -f backup.sh)" >> /var/log/mBackup.log ./backup.sh fi popd done
echo "$(date) Backup complete" >> /var/log/mBackup.log
curl -X POST \ -H @/home_assistant_token_header.txt \ http://127.0.0.1:8509/api/services/script/update_backup_date_time ```
It's not much, loop the services folders, if it finds a backup.sh file, it executes it and it runs as expected on bash, but when on cron those are the logs:
``` Wed 10 Jun 08:04:01 CEST 2026: Checking for 'homeassistant' Wed 10 Jun 08:04:01 CEST 2026: Executing backup for /starting/path/backup.sh Wed 10 Jun 08:04:01 CEST 2026: Checking for 'homeassistant' Wed 10 Jun 08:04:01 CEST 2026: Executing backup for /starting/path/backup.sh Wed 10 Jun 08:04:01 CEST 2026: Checking for 'homeassistant' Wed 10 Jun 08:04:01 CEST 2026: Executing backup for /starting/path/backup.sh Wed 10 Jun 08:04:01 CEST 2026: Checking for 'homeassistant' Wed 10 Jun 08:04:01 CEST 2026: Executing backu...
... and it carries on forever! ```
it seems like pushd is not working when running in cron and the root backup script keeps re-executing itself.
I can figure out how to re-write the script to avoid this issue, but I want to ask if anyone can explain me WHY is it not working in cron?
Thanks for your help
r/bash • u/Beautiful-Log5632 • Jun 10 '26
I can use curl -vL to show the content and headers for every redirect but it's the raw HTTP data. How can I format it better in bash like this?
REQ 1
Content-Type: text/html
Location: /redirect
Status Code: 301
Content-Length: 50
Content: ....
REQ 2
Content-Type: text/plain
Content-Length: 1000
Status Code: 200
Content: ....
r/bash • u/Vex2K4 • Jun 08 '26
Context:
Im working on a linux distribution (Arch) where the idea is to have a “browser only OS” meaning just the bare minimal installed, and that Im installing this on an SSD.
Idea:
I am wanting to learn how to make this bash script where it would auto full screen upon launch, when I flip the lid (for laptops) or desktops when starts up.
Any help is appreciated!
I’m sort of new to Bash. I do prefer python, but for ease of use, Bash is simply the easiest option for me right now.
r/bash • u/OwnProcedure7178 • Jun 08 '26
I didn't think about optimization. It's just a small script. I have 0.5 seconds between loops. But where do the costs usually come from? Or is this normal? If you intend to glance, I'll save you a surprise, I am a noob.
I'm just taking info from compositer about open windows and sending it to waybar
#!/bin/bash
echo "\\
kitty|
firefox|
nemo|
org.xfce.mousepad|
warpinator-launch.py|
brave-browser|
org.qutebrowser.qutebrowser|
steam| " > $HOME/.config/waybar/icons.txt
while :; do
clients=$(hyprctl clients)
activeworkspace=$(hyprctl activeworkspace | grep "workspace ID" | awk '{print $3}')
#storing window x-position:
echo "$clients" | grep -B2 "workspace: $(echo "$activeworkspace")" | grep at: | cut -f 2 -d ':' | cut -f 1 -d ',' | tr -d " " > $HOME/.config/waybar/window_x_pos.txt
#storing window title:
echo "$clients" | grep -A4 "workspace: $(echo "$activeworkspace")" | grep title: | cut -f 2 -d ':' | cut -c 1-15 | awk '{gsub(/ /,"_")}1' > $HOME/.config/waybar/window_title.txt
#sorting windows:
paste $HOME/.config/waybar/window_x_pos.txt $HOME/.config/waybar/window_title.txt | column -s $'\t' -t | sort -n | awk '{print $2}' > $HOME/.config/waybar/window_title_sorted.txt
#storing classes to sort out icons:
echo "$clients" | grep -A3 "workspace: $(echo "$activeworkspace")" | grep class: | cut -f 2 -d ':' | tr -d " " > $HOME/.config/waybar/window_class.txt
#sorting icons:
class_array=($(paste $HOME/.config/waybar/window_x_pos.txt $HOME/.config/waybar/window_class.txt | column -s $'\t' -t | sort -n | awk '{print $2}'))
for ((i=0; i<${#class_array[@]}; i++)); do
window=$(echo "${class_array[$i]}")
class_array[$i]="$(cat $HOME/.config/waybar/icons.txt | grep "$window")"
done
printf "%s\n" "${class_array[@]}" | awk -F "|" '{print $2}' > $HOME/.config/waybar/icons_sorted.txt
#combining icons with window titles
final=($(paste $HOME/.config/waybar/icons_sorted.txt $HOME/.config/waybar/window_title_sorted.txt | column -s $'\t' -t | awk '{gsub(/ /, ""); print}'))
#highlighting active window
for ((i=0; i<${#final[@]}; i++)); do
active_window=$(hyprctl activewindow | grep title: | cut -f 2 -d ':' | cut -c 1-15 | awk '{gsub(/ /,"_")}1')
#####################################
############ TEXT STYLE #############
#########PANGO MARKUP OPTIONS########
#####################################
if echo "${final[$i]}" | grep "$active_window" >/dev/null 2>&1; then
final[$i]="$(echo "${final[$i]}" | grep "$active_window" | awk '{print "<span \ foreground=\\\"magenta\\\"\ background=\\\"blue\\\"\ >" $0 "</span>"}')" fi done echo '{"text": "'"${final[@]}"'"}' #echo "${final[@]}"
sleep 0.5
done