How can I write a multi-line variable declaration to a file and then load it from the file elsewhere?
I have a variable declared over multiple lines:
INFO=$(cat \<<EOF
[
{"title": "ProjectName:", "value": "My Project"},
{"title": "Description:", "value": "Example"}
]
EOF
)
I need to write the variable to a file like this so I can load it and use it later somewhere else:
echo INFO=$INFO >> $env_file
When I load that file though the variable is malformed because it's over multiple lines:
source $env_file
cat $env_file
INFO= [
{"title": "ProjectName:", "value": "My Project"},
{"title": "Description:", "value": "Example"}
]
https://redd.it/1twqrf8
@r_bash
Why does printf behave differently in a subshell?
$ printf "%-9s:" "since"
since :
$ y=$(printf "%-9s:" "since")
$ echo $y
since :
Why is the format not working in the subshell? It's the same printf:
$ which printf
/usr/bin/printf
$ y=$(which printf)
$ echo $y
/usr/bin/printf
And it's the same shell:
$ echo $SHELL
/bin/bash
$ y=$(echo $SHELL)
$ echo $y
/bin/bash
$ /bin/bash --version
GNU bash, version 5.2.37(1)-release (aarch64-unknown-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
https://redd.it/1twnfff
@r_bash
Help getting buttons and actions working on a dunst notification
https://redd.it/1tvum2p
@r_bash
Problem with for loop in subshell
I have a problem executing a for loop under sudo, but under a subshell the problem is the same.
Simplified:for i in * ; doecho $idone
gives a list files in the current directory.. Butbash for i in * ; do echo $i ; done
gives the error "syntax error near unexpected token `do ". bash -c .... does the same.
I probably have to escape sortieing, but what? Could someone maybe explain?
Thanks/
https://redd.it/1tv4edq
@r_bash
learning bash ?
i just realized that i can very easily loose data (just lost a self hosted server of mine) and i want to learn how to do scripts to backup my files maybe daily and rewrite what i had on there if it changed but also not copy what did not change, where could i start ?
i know rsync has nice things to copy, and i could do it watch -n$(time) but i also would love to learn more because i want to make scripts for my i3blocks, i don't really use it to it's full just display basic data atm, one i tried to make a little dd scripts but it was a disaster and i nearly distroyed my pc
https://redd.it/1ttyv7w
@r_bash
Workflow CLI ottimizzato per la gestione SSH: come ho ridotto il tempo di switch tra server
Ciao a tutti,
Gestire un parco macchine via SSH tramite `~/.ssh/config` standard stava diventando inefficiente per il mio workflow. Ho scritto un'utility Bash che trasforma l'accesso remoto in un processo basato su menu interattivi:
* **Esperienza utente**: Invece di ricordare alias o digitare IP, lo script presenta un menu pulito, permettendo la selezione istantanea dell'host target.
* **Efficienza**: Ho ridotto drasticamente il tempo di latenza tra la scelta del server e l'ottenimento del prompt remoto, ottimizzando la gestione dei socket.
* **Semplicità**: Il tool è un unico file Bash che non richiede dipendenze, rispettando la filosofia di leggerezza dei sistemi Linux che utilizzo.
Il progetto è open source e disponibile qui: [LINK GITHUB](https://github.com/linux07source/ssh-manager-pro).
Sarei curioso di sapere: in ambienti con molti server, preferite mantenere configurazioni locali o utilizzate strumenti di astrazione per la selezione degli host? Come gestite la complessità quando il numero di macchine cresce?"
https://redd.it/1tt2s5n
@r_bash
read -p in background script?
What happens if read -p "Press [Enter] key to continue..." is run in background script?
Does it hang? etc.?
https://redd.it/1trs2uk
@r_bash
[VinMail] Bash-ing out emails: built a Bash-based terminal mail manager for multiple email accounts
https://redd.it/1tr5qf7
@r_bash
bai | AI shell-command helper
https://trans.github.io/bai/
https://redd.it/1tqin2j
@r_bash
[Project] Bashqueues: A shell-native, policy-driven IPC and job management system (Seeking technical feedback)
/r/linux/comments/1tpfynb/project_bashqueues_a_shellnative_policydriven_ipc/
https://redd.it/1tpfznh
@r_bash
Android AI screen sharing helped me learn Linux/Termux a LOT — can I do the same on Windows laptop?
I am starting to learn Linux, Git commands on Android using Termux, and the live screen sharing feature with ChatGPT / Gemini was very useful.
Tjey viewed my screen and corrected my errors etc. Felt like a tutor I never had.
Anyone else online I ask to be a mentor is either super busy or they don't understand how to talk to a total noob like me. Anyway no one else has tjat kind of time.
Now I’m moving more of my learning to my Windows Terminal.. Installed WLS.
Can this same be done on laptop ?
I checked chatgpt app on my laptop, it doesn't show same live screen sharing feature.
Any other workaround?
I just want it to view the screen, should not be able to do anything on the screen or perform anytask itself. Just guide me through voice amd chat.
Is it possible? Any workaround?
https://redd.it/1tozzkp
@r_bash
Built a terminal-native context extraction workflow for large repositories
i Built a small terminal tool called `grab` for debugging large repositories with ChatGPT/Claude.gi
The main issue I kept running into was context fragmentation.
You search across 10–15 files, paste partial snippets into the model, lose surrounding logic, and eventually the model starts hallucinating missing implementation details.
`grab` turns that into a more structured workflow:
grab --tree
grab auth
grab --functions server.py
grab 500 635 auth.cs
Each extraction appends into a continuously accumulated clipboard/tmux context buffer.
One thing that ended up working surprisingly well was recursive function indexing:
grab --functions .
This exposes exact function boundaries and line ranges, so the model can request additional implementation context explicitly instead of guessing hidden code paths.
The workflow becomes more like:
search → extract → accumulate → recurse
instead of repeatedly copy-pasting disconnected snippets.
Built on top of:
* ripgrep
* sed
* clipboard/tmux workflows
Currently supports:
* Python
* C#
* JS/TS
* shell repositories
Would genuinely be interested in feedback from people debugging large repositories with ChatGPT/Claude or similar tools.
Repo:
[https://github.com/johnsellin93/grab](https://github.com/johnsellin93/grab)
https://redd.it/1tng3vs
@r_bash
Bash overengineering AI agent
So Ive created an few md files to m my local agent overengineer bash scripts
Turned out pretty great...
Here is a link to the gemini gem if you want to try it out
gem link
And here is a little post I wrote on how Ive done it
My Bash Overengineering Assistant: A Blueprint for Building Specialized AI Architects
Hope someone will find it interesting
https://redd.it/1twyo1b
@r_bash
TIL that nmcli dev wifi can summarize connection rate, signal, bars, and security type by BSSID and SSID.
```bash
nmcli dev wifi
```
It has a man page, which I also appreciate.
I'm unsure it is what I would use for BASH scripting a data connection logger, but it is an easy command to get a peek at the available networks.
https://redd.it/1twoyts
@r_bash
A shell function for when you sort of know the command but not the exact flags
Honest use case: I can never remember tar/find/ffmpeg syntax. So I type something close to what I mean, let it fail, and run oops. It re-runs the command, captures stdout+stderr, sends the command + error to an LLM, and evals the corrected version if I confirm.
It works for plain typos too, but the part I actually use is "I know roughly what I want, fix my syntax."
https://github.com/TheSolyboy/oops
https://redd.it/1tw1tob
@r_bash
How are you moving scripts and command output between devices?
/r/ssh/comments/1tupb4z/how_are_you_moving_scripts_and_command_output/
https://redd.it/1tvcxnd
@r_bash
I ran rm -rf / inside a safe VM to show how fast Linux collapses (cybersecurity awareness demo)
A lot of beginners still copy/paste commands from forums, Discord, or GitHub without checking what they do.
So I made a short, dramatic demo showing what happens when you run the infamous destructive command:
rm -rf /
Don’t worry — everything was done inside a throwaway VirtualBox VM with snapshots.The goal isn’t to “destroy Linux for fun,” but to show:
• Why this command is so dangerous
• How attackers hide it inside malicious scripts
• How to audit shell scripts safely
• Why you should always test in a VM first
If you’re learning Linux, cybersecurity, or building a homelab, this might save you from a very bad day.
Video link in the first comment to respect subreddit rules.
Guided Links:
Linux safety
VirtualBox labs
https://redd.it/1tupice
@r_bash
Removed by Reddit
Removed by Reddit on account of violating the [content policy. ]
https://redd.it/1tt2d4e
@r_bash
Bash Script notify-send
/r/linuxquestions/comments/1tsfj3q/bash_script_notifysend/
https://redd.it/1tsfjo1
@r_bash
I built a website to create custom prompts for bash and zsh
https://redd.it/1trdd7i
@r_bash
[VinMail] Bash-ing out emails: built a Bash-based terminal mail manager for multiple email accounts
https://redd.it/1tqwgve
@r_bash
Seeking advice: focus on advanced bash, learn basic python or both?
Hello all,
I want some advice as to what will be best to focus my attention on based on my situation. I work as a sysadmin/linux engineer and naturally I do quite a lot of bash scripting on the server side for reporting, troubleshooting, scheduling/automating.
I have been learning basic python from the automate-the-boring-stuff book as I never actually got into programming and felt I need a more "serious" language in my resume.
However in this sub I see a lot of bash code which seems quite advanced and in all fairness I didn't even now you can do some of these things with bash.
I don't intend to transition to a developer role but I believe being able to write more complex automation from scratch will make me a better "product" on the job market.
Questions:
For server side - when to use bash and when to use python?
What can python do for a sysadmin / engineer that bash can't?
Would you say it's more valuable to know bash at an advanced level rather than knowing both bash and python at a basic-intermediate level for someone in my field?
What would you consider advanced level of knowlegde in bash?
https://redd.it/1tq41ed
@r_bash
I hope you find this script useful
I'm a new blogger on medium. I'm trying my best to write efficiently. Here is my new post. Please give me your thoughts.
In this article, I’ll walk you through analyzing table space usage and row counts using SQL Server system views and DMVs which is useful for performance tuning and database growth monitoring.
joyshaw987/analyzing-table-space-and-row-counts-68a21a81013d" rel="nofollow">https://medium.com/@joyshaw987/analyzing-table-space-and-row-counts-68a21a81013d
https://redd.it/1tprv3u
@r_bash
sharing a folder of markdown with someone who doesnt want to unzip anything
ok so i had this dumb problem. got a folder with like 4 markdown files (readme, sources, conventions file) i wanted to hand to someone on my team. the options were zip it, paste each file one by one, or throw it in a gist.
none felt right for 3kb of text. zip is overkill, gist splits it into one file per url, pasting loses the directory structure entirely.
wrote a thing that packs a directory into one self-describing markdown file. fold ./my-notes gives you my-notes.folded.md. recipient runs unfold my-notes.folded.md and gets the directory back. bash, no deps. the folded file is plain markdown with section delimiters so you can read it in a browser or text editor without unfolding, kinda like a human-readable shar.
(full disclosure: my project, fold.dom.vin)
mainly wondering if anyone else hits this specific annoyance and what you use. i know shar exists but wanted something you can actually read as-is without running it.
https://redd.it/1tpdr5t
@r_bash
grep: Piping command output into grep -f <pattern file> isn't working
Hey everyone, hope you're having a nice day.
I have 4 files (A-D) and a text file (T) in a directory. T contains the MD5 checksums of A-D on individual lines output directly from md5sum, i.e. the form <checksum> <file>, as well as a bunch of other lines. I want to take the MD5 checksums of A-D and check that they match the ones in T.
The command I've come up with is md5sum <directory>/* | grep -f T. This command takes the checksums of A-D and T, then gives it to grep to see if they match the checksums in T. However, the standard output I am getting from this command is the checksums of A-D and T, but T doesn't contain its own checksum, so why is this happening? Curiously, the lines output from the command aren't highlighted, if I do a test grep, the matching characters appear in bold red, but these lines appear as standard white characters.
Thanks!
https://redd.it/1tom2wc
@r_bash
Minimalist natural language to shell command assistant
https://github.com/Omodaka9375/ai-in-a-shell
https://redd.it/1tnc55h
@r_bash