The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [bash]

BASH is the GNU Bourne Again SHell, the successor to the classic Unix Bourne sh (shell). It's the default shell for various GNU systems.

Filter by
Sorted by
Tagged with
6
votes
1answer
72 views

Install Python script requirements

Sometimes I download a Python script (from a trusted source), and can't run it because of missing dependencies, which I have to install one by one (no ...
2
votes
1answer
109 views

Dompdf LFI (Local File Inclusion)

Intro During a CTF I encountered a dompdf LFI vulnerability, which is explained at exploitdb. However when I executed that vulnerability it gave it to me in PDF form, and it was a pain to constantly ...
4
votes
3answers
69 views

Write bootable image to USB device

Recently, I've been making and refining installer and rescue images to boot from USB media, in the form of CD-ROM or hard disk images. After a few occasions where I re-ran the command after removing ...
3
votes
2answers
67 views

Moving files and leaving links in bash

The objective of this code is to create a command that move files and leaves links in their place. I'm just a beginner in shell scripting and it would be quite useful to hear your opinions on how to ...
8
votes
2answers
173 views

Identify users who have logged in as root

This is a program written in Python 3.x and Bash to check and find any users who have logged in as root via sudo su, sudo -i, ...
2
votes
2answers
240 views

Bash script to generate and change Java keystore passwords

This is the first Bash script I've written, so I'm looking for feedback on best practices, conventions, things like that. This script makes a few assumptions There is a java keystore stored at ...
1
vote
1answer
113 views

Read integers from text file and write to CSV file

Background: I've recently started learning bash due to my new job in a VFX company. We backup all of our media to LTO tapes (one master and one clone). I was tasked with writing a script that split ...
2
votes
1answer
51 views

Small bash script to enhance virtual environments on directory navigation

Ages ago I made a small bash script which would add a command cdp, standing for "change directory - project". What it did was ...
4
votes
0answers
70 views

appleseed command line widget (CLW)

─── appleseed on GitHub appleseed v1.0.0 is a command line widget (CLW), I designed for macOS and iTerm2. Its a flexible platform for process automation and added eye candy. It utilizes ...
2
votes
1answer
28 views

Finding (and counting) duplicate JS/Java files

I have the following script which takes minutes to give output. ...
1
vote
1answer
40 views

Nginx-WordPress conf

This is how I create am Nginx virtual host for a WordPress webapp. I did best to keep it as minimal as I can while having a working webapp. Please review it: ...
2
votes
2answers
95 views

Nginx-WordPress installer for Debian

I have written the following Bash script which includes an Nginx WordPress bootstrapper: A program establish WordPress apps fast on a Debian-Nginx environment. It utilizes CertBot for HTTPS, SSHguard ...
7
votes
2answers
208 views

Bash script to temporarily run a shell without certain group memberships

I have here a script called rwog (run without groups) that allow a user to run a shell without particular group memberships. ...
3
votes
1answer
2k views

Rsync script that does Daily, Weekly and Monthly backups with hard links

I have not been able to find a good implementation of using rsync to do daily, weekly and monthly backups with hard links anywhere. So I wrote my own and I am now looking for critique before I set it ...
4
votes
3answers
103 views

Un*x terminal history wiper

Using various answers from Stack Overflow and Ask Ubuntu, I've hacked together this simple C program that wipes terminal history. It works but I'm relatively new to C so I'm not sure if everything is ...
4
votes
1answer
112 views

A bash prompt that includes battery level & git branch

Is there a better way to handle the color codes and display git branch and battery percentage? ...
3
votes
2answers
52 views

Bash script for managing hashtag notes

I have written a simple script for managing hashtag notes. I am not familiar with bash scripting so I would really appreciate it if someone could give me some pointers about it. ...
3
votes
1answer
294 views

Reset files in Git which show as modified but have no changes according to “git diff”

This seems to be working but also is quite horrendously slow and seems a little hacky to me. ...
0
votes
1answer
40 views

MySQL CLI: Create a MySQL user & DB

Please review my Bash code to create an authenticated, all privileged MySQL user plus a DB with the same name, through the MySQL CLI: ...
1
vote
1answer
49 views

Using extdebug to display where a function was defined

I wrote a tool similar to which that would display the file and line number where a function was defined. Is there a way I can do the same for aliases? Also, any ...
3
votes
1answer
80 views

Create a WordPress site data with Nginx app data automatically

The following script is aimed for Ubuntu >=16.04 LEMP environments with PHP-FPM >=7.0, MySQL, WP-CLI, Certbot, and ...
1
vote
1answer
35 views

Four-lines script to make an immediate DB and document root zip backup

What do you think of my script to make an immediate DB and document root zip backup? Any flaw you might find. Please inform me of it: ...
4
votes
2answers
53 views

Bash function to generate colored output

I like to user colored output in my interactive shell scripts. I've been using Ubuntu and bash for a long time, but haven't done much bash scripting. I'd appreciate a review of this function for ...
5
votes
2answers
86 views

Goodgame Empire coin collector with random offsets in (almost-POSIX) Bash

Today, my goal was again to improve my POSIX shell scripting abilities. In one MMO game called Goodgame Empire, there is possible to code yourself a coin (tax) collector. But that's of less ...
4
votes
2answers
77 views

Measuring typing speed in terminal without a mistake

I tend to dislike my code. It's always a mess. I can't critique my own code though, because I just turn it into another mess. I've been programming slightly better every year, but this year it has ...
4
votes
0answers
219 views

WSL LAMP stack script

The following code is aimed to establish a WSL based LAMP environment. This is instead XAMPP or WAMPP based LAMP environment which doesn't allow Bash. The script includes a cat heredocument called "...
2
votes
1answer
49 views

Changing php.ini with code in a LEMP stack on Debian systems

This is how I establish a Debian LEMP and use code to change php.ini directives, as part of php-fpm. Please review the way I change ...
2
votes
1answer
33 views

S3 Bash Tools Part 3

This is a follow on to a previous question: Part 3: User Scripts All the code I am submitting here is available in github The reason to write these tools is so I can prototype and quickly verify ...
1
vote
0answers
21 views

S3 Bash Tools Part 2

This is a follow on to a previous question: Part 2: Upload/Download All the code I am submitting here is available in github The reason to write these tools is so I can prototype and quickly ...
1
vote
0answers
66 views

S3 Tools in Bash

This is a follow on to a previous question: Part 1: Signature All the code I am submitting here is available in github The reason to write these tools is so I can prototype and quickly verify ...
1
vote
1answer
56 views

Ubuntu-Nginx lightweight server environment setup

Please review the following Bash script that uses to establish a "lightweight" Ubuntu-Nginx server environment mainly aimed to run small WordPress sites (about 5 plugins, about 25 webpages, about 25 ...
2
votes
1answer
94 views

Nix cron daily and weekly scripts for a minimal Nginx server environment

I've created the following Nix cron for daily and weekly scripts for a minimal Nginx server environment (as part of my larger script). The daily cronjob updates WordPress and brings back original ...
2
votes
1answer
104 views

Webapp Substrate script for WordPress on Debian-Nginx

The following script creates a webapp substrate for WordPress webapps/websites on Ubunu-Nginx with PHP-FPM and Mysql environments, with Certbot, while all software is uncustomized. Such substrate ...
3
votes
3answers
1k views

Bash script to perform LUHN check

The following Bash script takes a single parameter (the PAN) and exits with 1 if the PAN does not satisfy a LUHN check. ...
3
votes
2answers
60 views

Password string generation

I'm trying to create passwords using the following snippet to match a custom password policy. I've added three gtr statements, at the end of the string, to ...
2
votes
3answers
575 views

Shell script to parse variable definitions from Scala build file

The build.sbt text file contains versions like this: name := "happy" scalaVersion := "2.11.8" sparkVersion := "2.2.0" I wrote ...
5
votes
2answers
71 views

Determine if .deb package is installed using Bash

I was able to use dpkg-query to determine if a package is installed on Ubuntu, but it's a bit of a mess because the name used to install the package doesn't always align with what it's installed as. ...
3
votes
1answer
599 views

Bash script that checks for package dependencies and installs them if necessary

I'm new to writing bash scripts and was wondering if I could get someone's advice on a part of the script I'm working on. Intended purpose of code Check if a package exists using ...
3
votes
1answer
296 views

Finding a Bash script's Runfiles as generated by Bazel

When building a sh_binary with dependencies using Bazel, a tree of Runfiles containing the dependencies is generated: ...
1
vote
1answer
28 views

Script that makes an API call to and parses the response to get a URL from where to download another file

This is my first script and I am having a hard time writing the shortest possible code. ...
3
votes
2answers
48 views

Safely pruning merged topic branches locally

Background My team develops in a git monorepo. User stories are broken into very small discrete sub-tasks and merged directly into master, rather than into a ...
6
votes
3answers
209 views

Shell script to count chess game outcomes

I came across this blog post by Adam Drake from around a year ago which is now making the rounds again. I made some improvements to his code, but wish to see if there are additional tweaks that could ...
2
votes
1answer
139 views

Shell script to create a boilerplate proyect

This is actually my first shell script and just by looking at it I know this can look better. I use Elixir and Phoenix for most of my projects and I started using Zurb Foundation 6, changing from ...
4
votes
1answer
72 views

Restart network-manager service if connection down on wake shell script

I use Ubuntu (Trusty and Xenial) and usually put my computer in sleep mode rather than power it down. A common problem is that upon wake the network is down so one has to restart the network-manager ...
3
votes
0answers
116 views

Follow-up: Script to create symlinks for dotfiles in a Git repository

This is a follow up to my previous question on Code Review. I did try to implement most of feedback provided by thiagoalessio. This is what my updated code looks like: ...
4
votes
1answer
330 views

Script to create symlinks for dotfiles in a Git repository

I have a GitHub repository containing all my dotfiles for bash, tmux and neovim. I'm using a ...
3
votes
0answers
32 views

Bash webapp duplicator

I've written the following Bash script used to duplicate a webapp/website you have (say, a Wordpress website) locally on your server environment, for testing purposes, indicating after 2 days if you ...
1
vote
1answer
54 views

Verify that a CSV file contains a backup job for every prod job

This is a list of jobs in autosys. What I have to do is make sure that every job in PROD has a accompanying job in BACKUP. The jobs are formatted as ...
2
votes
1answer
93 views

Bash - Compile C++ File Function

As I am starting to be tired of reverse-searching in history for the C++ compile command, which I'm using - details on my flags are written here, I defined the following ...
2
votes
1answer
68 views

Bash script to validate a MySQL database

I am fairly new to bash script programming so I would love some feedback. I am trying to write a series of migration scripts for our DBs (please don't direct me to other tools; I spent a lot of time ...