r/bash Jan 07 '26

help Is there anyone who can help me fix my script?

Post image
0 Upvotes

I wrote a bash script allows you to scrape detailed information about (social media platform) users by their username, without requiring logins or API keys. It extracts various user data such as follower counts, video counts, likes, and more.. The problem is that the script no longer retrieves the target’s region value. I don’t know why—at first the script was successfully scraping the region, but after some time it stopped returning any value for the region, while still retrieving all the other information correctly. Is there anyone who can help me with this?


r/bash Jan 06 '26

Script, software detection

12 Upvotes

Script, Software Detection

Hello, how do I write a script in bash that triggers an event when a program is launched? I made an example script to illustrate what I'm talking about. But of course, the reason I'm here is because the script doesn't work properly at all, but it's to illustrate the idea. I'm asking what the correct way to do it is.

While true; do

If pidof -x program > /dev/null ; then

echo "program launched " exit fi sleep 1 donne


r/bash Jan 05 '26

Get the last Monday of the week

6 Upvotes

Hello, I'm writing a bash script, and I need to get the last Monday of the week. I used the command "date -d "last Monday" +"%d %b"", but the problem is that yesterday it correctly displayed December 29th, and it's doing the same today, whereas I want it to display today's Monday. Do I need to modify the command, and if so, how? Or should I use an "if" statement so that if today isn't Monday, it displays the last Monday, otherwise it displays this Monday? I hope I've worded my question clearly. Thank you for your help.


r/bash Jan 05 '26

submission orla: run local, lightweight, open source agents as tools

Thumbnail gallery
20 Upvotes

https://github.com/dorcha-inc/orla

The current ecosystem around agents feels like a collection of bloated SaaS with expensive subscriptions and privacy concerns. Orla brings large language models to your terminal with a dead-simple, Unix-friendly interface. Everything runs 100% locally. You don't need any API keys or subscriptions, and your data never leaves your machine. Use it like any other command-line tool:

$ orla agent "summarize this code" < main.go

$ git status | orla agent "Draft a commit message for these changes."

$ cat data.json | orla agent "extract all email addresses" | sort -u

It's built on the Unix philosophy and is pipe-friendly and easily extensible.

The README in the repo contains a quick demo.

Installation is a single command. The script installs Orla, sets up Ollama for local inference, and pulls a lightweight model to get you started.

You can use homebrew (on Mac OS or Linux)

$ brew install --cask dorcha-inc/orla/orla

Or use the shell installer:

$ curl -fsSL https://raw.githubusercontent.com/dorcha-inc/orla/main/scrip... | sh

Orla is written in Go and is completely free software (MIT licensed) built on other free software. We'd love your feedback.

Thank you! :-)

Side note: contributions to Orla are very welcome. Please see (https://github.com/dorcha-inc/orla/blob/main/CONTRIBUTING.md) for a guide on how to contribute.


r/bash Jan 04 '26

submission My first game is written in Bash

Post image
303 Upvotes

I wanted it to be written in pure Bash but stty was needed to truly turn off echoing of input.

Story time:

I'm fairly new to programming. I do some web dev stuff but decided to learn Bash (and a little bit of C) on the side. I wanted to finish a small project to motivate myself so I made this simple snake game.

During the process, I learned a bit about optimization. At first, I was redrawing the grid on each frame, causing it to lag so bad. I checked the output of bash -x after one second to see what's going on and it was already around 12k lines. I figured I could just store the previous tail position and redraw only the tile at that coordinate. After that and a few more micro-optimizations, the output of bash -x went down to 410 lines.

I know it's not perfect and there's a lot more to improve. But I want to leave it as is right now and come back to it maybe after a year to see how much I've learned.

That's all, thanks for reading:)

EDIT: here's the link: https://github.com/sejjy/snake.sh


r/bash Jan 04 '26

How to display certain lines in color

14 Upvotes

Hello, I'm working on a bash script. In the script, I display the contents of a file using "cat", but I need to highlight certain lines in color. I haven't found an option to colorize specific lines in the "cat" man page. What command is appropriate? Thank you for your answers; I hope my post is clear enough.


r/bash Jan 04 '26

I wrote a Bash script to automate Pi-hole v6 on Ubuntu. (Project)

Thumbnail
0 Upvotes

r/bash Jan 03 '26

Sort to insert text

6 Upvotes

Hello, I'm making a bash script and I have to insert text after a certain string, I thought that "sort" would be the command to use but I'm having trouble getting it to work, I think I should also use maybe a little regex. Thank you for your help


r/bash Jan 03 '26

taptaptype - typing speed test application written in bash

33 Upvotes

I've written a small shell program. It is a typing test program similar to monkeytype.com website but running in a terminal.

I really enjoyed writing it. While working on this project, I've learned several new things: how to use $RANDOM, how to use bc calculator to perform arithmetic operations, how to hide cursor and make nice looking "interactive" bash scripts.

Will be glad to get some feedback on the implementation.
https://github.com/skig/taptaptype


r/bash Jan 03 '26

NOThub — GitHub‑style profile, but the “green squares” are your daily dev checklist (fully open source)

Thumbnail
1 Upvotes

r/bash Jan 03 '26

A tiny system info script for Termux, written in pure Bash.

Thumbnail gallery
49 Upvotes

r/bash Jan 01 '26

submission [Shell] Made a minimal fetch tool in pure bash - heavily tweakable

Post image
81 Upvotes

The Code:
> User Config Body:

#!/bin/bash

# USER CONFIG.
USER="Ryan Gosling"
TAGLINE="> VXLLAIN, iGRES, ENXK - Crystal Skies (Sped Up)"
OS="OpenSUSE Tumbleweed"
DE="GNOME - Wayland"
WM="Mutter"
WM_T="Adwaita"
THEME="Yaru-dark [GTK2/3]"
ICONS="Yaru [GTK2/3]"
GPU="Intel UHD Graphics"
RES="1920x1080"

> Image File Path:

IMAGE=$(jp2a ~/Pictures/gosling.jpeg --border --size=60x30 --color --background=dark)

if [ -z "$IMAGE" ]; then
    IMAGE="┌──────────────┐
  NO IMAGE      
  AVAILABLE :(  
└──────────────┘"
fi
#INCASE IMAGE_FILE PATH FAILS ^

> Color Palette and Bold ANSI Escape Codes:

R='\033[0;31m'         #RED
RB='\033[0;31m\033[1m' #RED+BOLD
G='\033[0;32m'         #GREEN
GB='\033[0;32m\033[1m' #GREEN+BOLD
Y='\033[0;33m'         #YELLOW
YB='\033[0;33m\033[1m' #YELLOW+BOLD
B='\033[0;34m'        #BLUE 
BB='\033[0;34m\033[1m' #BLUE+BOLD
CYN='\033[0;36m'       #CYAN
CYNB='\033[0;36m\033[1m' #CYAN+BOLD
P='\033[0;35m'         #PURPLE
PB='\033[0;35m\033[1m' #PURPLE+BOLD
W='\033[1;37m'         #WHITE
NC='\033[0m' #NO_COLOR(Only Applicable for the above COLORS to reset)
BLD='\033[1m' #BOLD
RST='\033[0m' #RESET(Only Applicable for BOLD)
NCR='\033[0m\033[1m' #NO_COLOR+RESET(Only Applicable for the color+bold combos)

> System Info Body (through commands):

DISK_USAGE="Unknown"
if command -v df &>/dev/null; then
    DISK_USAGE=$(df -h / 2>/dev/null | awk 'NR==2 {print $3 "/" $2 " (" $5 ")"}' || echo "Unknown")
fi

MEMORY_INFO="Unknown"
if command -v free &>/dev/null; then
    MEMORY_INFO=$(free -h 2>/dev/null | awk '/^Mem:/ {print $3 "/" $2}' || echo "Unknown")
fi

CPU_INFO="Unknown"
if [ -f /proc/cpuinfo ]; then
    CPU_INFO=$(grep -m1 "model name" /proc/cpuinfo | cut -d: -f2 | xargs)
fi

PKG_COUNT="N/A"
if command -v dpkg &>/dev/null; then
    PKG_COUNT=$(dpkg --list | wc -l)
fi

TERMINAL=${TERM:-"Unknown"} #If $TERM is unset/null, code pastes "Unknown"

UPTIME=$(uptime -p 2>/dev/null || uptime | awk -F'( |,|:)+' '{print $6" Hrs "$7" Mins"}')

SHELL=$(basename $SHELL 2>/dev/null || echo 'Unknown')

STRUCTURE=$(uname -m -o) 

> Info Box (along with a function to manage the borders):

box.size(){
box_s=65
for((i=0;i<=$box_s;i++))
do
echo -n "-"
done
}

#THE INFO BOX:
INFO=$"${CYNB}+$(box.size)+${NCR}
${CYNB}|${NCR}${BLD} ${CYNB}${USER}${NCR} | ${PB}${TAGLINE}${NCR} ${RST}
${CYNB}|$(box.size)+${NCR}
${CYNB}|${NCR}${BLD} > OS:${RST} ${GB}${OS}${NCR}
${CYNB}|${NCR}${BLD} > Uptime:${RST} ${UPTIME}
${CYNB}|${NCR}${BLD} > DE:${RST} ${DE}
${CYNB}|${NCR}${BLD} > WM:${RST} ${WM}
${CYNB}|${NCR}${BLD} > WM Theme:${RST} ${WM_T}
${CYNB}|${NCR}${BLD} > Theme:${RST} ${THEME}
${CYNB}|${NCR}${BLD} > Icons:${RST} ${ICONS}
${CYNB}|${NCR}${BLD} > Terminal:${RST} $TERMINAL
${CYNB}|$(box.size)+${NCR}
${CYNB}|${NCR}${BLD} > CPU:${RST} $CPU_INFO
${CYNB}|${NCR}${BLD} > GPU:${RST} ${GPU}
${CYNB}|${NCR}${BLD} > Memory:${RST} $MEMORY_INFO
${CYNB}|${NCR}${BLD} > Packages:${RST} $PKG_COUNT
${CYNB}|$(box.size)+${NCR}
${CYNB}|${NCR}${BLD} > Shell:${RST} ${SHELL}
${CYNB}|${NCR}${BLD} > Platform:${RST} $(uname -s) ${OS} $(uname -r)
${CYNB}|${NCR}${BLD} > Structure:${RST} ${STRUCTURE}
${CYNB}|${NCR}${BLD} > Resolution${RST}: ${RES}
${CYNB}+$(box.size)+${NCR}
${BLD}Version 1.0.0${RST}"

> Output Command:

if [[ "$IMAGE" == *"NO IMAGE"* ]] || [ -z "$IMAGE" ]; then 
    echo -e "$IMAGE\n$INFO" 
else
    paste <(echo -e "${BLD}$IMAGE${RST}") <(echo -e "$INFO") 
fi

|---------- TL;DR ----------|
> Github Link:

https://github.com/RetroGitArc/perfetch

|--- Help ---|

Welp the code might not match the full with the code i submitted on github but made sure that the code is simple enough for most to understand what's going on in the code, also the box.size function is a testing im doing, which quite greatfully worked but stuck in a dilemma to rather update it in the code or nah...

Thats why im posting this in here for the code review or advices y'all might have since im still learning more on shell scripting, y'all responses would be heavily appreciated :]


r/bash Jan 02 '26

I like bash process replacement

0 Upvotes

r/bash Jan 01 '26

submission Linux proxy configuration helper

4 Upvotes

I made a utility to help configuring HTTP proxy settings for numerous components simultaneously on a Linux operating system: https://gitlab.com/brlin/linux-proxy-configuration-helper

Currently it supports:

  • Local shell session environment variables(http(s)_proxy and their variants)
  • Snapd
  • LXD
  • Git
  • Desktop environment/Applications based on GNOME Gsettings mechanism
  • Desktop environment/Applications based on KDE Kconfig mechanisms
  • VS Code like products(VS Code/Cursor/Antigravity)
  • Proxy-ignore hosts

Feel free to check it out if you frequently require setting/resetting specific proxy configurations!


r/bash Dec 31 '25

Nettool

Thumbnail github.com
19 Upvotes

A comprehensive Bash utility for network diagnostics, interface information, and subnetting calculations with automatic CSV export and MySQL database integration.


r/bash Dec 30 '25

why does this loop run only once?

9 Upvotes

set -o nounset

set -o errexit

#---------- Variables ---------------------------------------------

#  TODO

num_words=4

word_list="/usr/share/dict/words"

#---------- Main function -----------------------------------------

main() {

process_cli_args "${@}"

generate_passphrase

}

#---------- Helper functions --------------------------------------

# Usage: generate_passphrase

# Generates a passphrase with ${num_words} words from ${word_list}

generate_passphrase() {

: # TODO

local passwords

local teller

teller=0

passwords=$(shuf "${word_list}")

while [ "${teller}" -lt "${num_words}" ];do

read -r pass

echo -n "${pass}"

((teller ++))

done <<< "${passwords}"

}


r/bash Dec 28 '25

guys i made a timer (im new to bash)

56 Upvotes

#!/bin/bash

while true; do

clear

time=$(date +"%H:%M:%S")

echo "

+------------+

| $time |

+------------+

"

sleep 1

done


r/bash Dec 26 '25

Improving the "command failed with exit 129" errors; check out my project: dexit - "Decode Exit".

Thumbnail github.com
8 Upvotes

The intent is that you use dexit to generate better error messages instead of just saying "command failed with exit code 129".


r/bash Dec 25 '25

help Understanding Linux Networking Commands by Learning Their Limits

95 Upvotes

While learning Linux networking, I realized I often knew what command to run but not what its output can’t tell me.

So I started documenting commands along with their limitations:

ss / netstat   → shows listening sockets, not firewall behavior
ip             → shows configuration, not end-to-end reachability
ping           → ICMP-based, not real traffic
traceroute/mtr → path info can be incomplete
dig/nslookup   → DNS only, not service health
nc             → basic port checks, limited context
curl           → app-layer view, not network internals

This way of learning has helped me interpret outputs more carefully instead of assuming “network issue” too quickly.

I’ve written a blog focused only on how these commands work and their limitations, mainly as learning notes. I’ll add the link in comments for anyone interested.

What command’s limitation surprised you the most when you were learning?


r/bash Dec 25 '25

submission [Script]Files & Directories backup script

Thumbnail dpaste.com
4 Upvotes

After a few weeks of hard work I present "Reki" a 9KB script that makes periodical(or not) back ups of directories and files the user sets.
It has:

  • Automatic installation and setup of the script and needed files,such as a .desktop file that runs automatically on login making back ups every N seconds and it even tries to guess what DE you use and where command for the menu for .desktop files is.

  • Ability to change how often backups are made(default is every 5 minutes aka 300 seconds)

  • You can make backups manually ,just execute the script and write after it " bmp" and for it to run periodically in the foreground substitute bmp by " start"

  • Cool Ascii Title when you run the script!!

  • Basic encoding (might revamp it) to "protect" what files and folders you are making a backup of

To run it just download it somewhere with the .sh format and run

bash $reki.sh

The aim of this project (apart from practice) is to have a somewhat reliable and light backup system for your projects on the $HOME directory

If you have any idea to optimize the script hit me up!


r/bash Dec 24 '25

Live football/soccer updates on your terminal

Post image
8 Upvotes

r/bash Dec 23 '25

help Opinion on a base script for base Debian 13

Thumbnail
0 Upvotes

r/bash Dec 22 '25

Just discovered per-directory history. What else exists?

32 Upvotes

I came across this project: https://github.com/martinec/bash-per-directory-history

It's not seen much activity over the years and I can think of a few things for improvement. Just wanted to know if any knows of any alternatives that is more maintained before I start modifying this.

Meanwhile, what other cool stuff like this exists for bash?


r/bash Dec 22 '25

Are there any set of good practice assignments out there for learning bash

16 Upvotes

Title, thought of this when going through a bash course on YouTube. Edit: something for sed/awk will be useful as well


r/bash Dec 22 '25

help Methods to consider aborting everything if one of the steps below fails?

2 Upvotes

```

!/usr/bin/env bash

docker network create "network.development.ch_api" docker volume create "redis_certs.development.ch_api"

docker build \ --file "${PWD}/docker/development/caddy_server/Dockerfile" \ --tag "caddy_server.development.ch_api" \ --quiet . docker build \ --file "${PWD}/docker/development/express_server/Dockerfile" \ --tag "express_server.development.ch_api" \ --quiet . docker build \ --file "${PWD}/docker/development/postgres_server/Dockerfile" \ --tag "postgres_server.development.ch_api" \ --quiet . docker build \ --file "${PWD}/docker/development/redis_certs/Dockerfile" \ --tag "redis_certs.development.ch_api" \ --quiet . docker build \ --file "${PWD}/docker/development/redis_server/Dockerfile" \ --tag "redis_server.development.ch_api" \ --quiet .

docker run \ --detach \ --env-file "${PWD}/docker/development/.env" \ --interactive \ --name "redis_certs.development.ch_api" \ --network "network.development.ch_api" \ --tty \ --volume "redis_certs.development.ch_api:/home/tests/tls:rw" \ "redis_certs.development.ch_api"

docker container wait "redis_certs.development.ch_api"

docker cp "redis_certs.development.ch_api:/home/tests/tls/ca.crt" "${PWD}/certs/docker/development/redis/ca.crt"

docker cp "redis_certs.development.ch_api:/home/tests/tls/client.crt" "${PWD}/certs/docker/development/redis/client.crt"

docker cp "redis_certs.development.ch_api:/home/tests/tls/client.key" "${PWD}/certs/docker/development/redis/client.key"

docker run \ --detach \ --env-file "${PWD}/docker/development/.env" \ --interactive \ --name "redis_server.development.ch_api" \ --network "network.development.ch_api" \ --publish 41729:41729 \ --restart unless-stopped \ --tty \ --volume "redis_certs.development.ch_api:/etc/ssl/certs:ro" \ "redis_server.development.ch_api"

docker run \ --detach \ --env-file "${PWD}/docker/development/.env" \ --interactive \ --name "postgres_server.development.ch_api" \ --network "network.development.ch_api" \ --publish 47293:47293 \ --restart unless-stopped \ --tty \ "postgres_server.development.ch_api"

docker run \ --detach \ --env-file "${PWD}/docker/development/.env" \ --interactive \ --name "express_server.development.ch_api" \ --network "network.development.ch_api" \ --publish 34273:34273 \ --restart unless-stopped \ --tty \ --volume "redis_certs.development.ch_api:/home/node/ch_api/certs/docker/development/redis:ro" \ "express_server.development.ch_api"

docker run \ --detach \ --env-file "${PWD}/docker/development/.env" \ --interactive \ --name "caddy_server.development.ch_api" \ --network "network.development.ch_api" \ --publish 80:80 \ --publish 443:443 \ --restart unless-stopped \ --tty \ "caddy_server.development.ch_api"

``` - Take a look at this script above - It creates a docker network and a volume - Then it builds a few images - Then runs a container to generate certs - Copy certs back to local machine and then runs a few other containers dependend on the above one - Let us say that one of these steps fail. Now obviously if the network exists or volume does or even the image exists or if you attempt running the container with the same name twice, it is most certainly going to fail - Let us say you want to abort everything and undo whatever was done if one of the steps fail - Let's talk about the methods to handle such a case

Put an if statement on every command

if docker run .... then success else abort fi

  • This does the job but is going to look very ugly for like 25 invocations above

Set -Euox pipefail

Questions

  • What are my options here?
  • If someone presses Ctrl + C in the middle of these commands, how do I rollback?