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
2answers
617 views

Bash script that counts the characters, frequency, and percentage of letters in Spanish sonnets

This script will be used to analyze a lot of old Spanish sonnets. I have tested it thoroughly and all seems to be working perfectly. However, I want to make sure I am not missing some detail because I ...
6
votes
2answers
137 views

Find prime factors and reverse strings

I'm currently taking an introductory course to Bash at my university, and was hoping to get some peer-review from whoever might have some time. Full disclosure: the quality of the code isn't ...
6
votes
2answers
414 views

A baby monitor using a Raspberry Pi to send push notifications when triggered by noise

I have a Raspberry Pi 3B with a USB microphone. I have used a combination of Bash and Python scripts to detect noise levels above a certain threshold that trigger a notification on my phone. The ...
6
votes
2answers
2k views

Function autoloading in bash

I'm wondering if anyone can code review my code below. That's the core code of my little framework for bash in GitHub. ...
6
votes
1answer
226 views

Statistical simulation

I've written the following program as a submission to the German Federal Computer Science Competition for highschool students. The program makes the following simulation with a given number of days ...
6
votes
2answers
91 views

A replacement for OSX's path_helper

I was having problems setting my path the way I wanted, I turned to Apple's path_helper but found it appends system dirs to the beginning of the path. I found someone had made a start on a replacement ...
6
votes
1answer
21k views

Replacing values in json file with jq

I have a JSON file like ...
6
votes
1answer
356 views

Notification script | from RSS to Email | Bash

This is a script that must send an email at each new article published on a specific website. Any suggestions or improvements to do? ...
6
votes
3answers
148 views

Back up or restore home directory

I am currently trying to learn bash scripting and I've made a script that backs up or restores my home folder. My main question is whether my code is readable or very messy. I would love to learn to ...
6
votes
1answer
504 views

Git commit-msg URL shortener

I have just written my first git hook script. It is very simple that simply finds any URLs in the commit message and uses the Google URL shortener to rewrite the URL nicely. it is located here. I ...
6
votes
1answer
278 views

How to improve my auto-reconnection Python script

I need some feedback here. Due to a weird issue on my server system, the network card disconnects from the network regularly. I'll fix this at a later date. But I wanted to know if the below script ...
6
votes
1answer
70 views

Simple bash script creates apache2 virtualhost config for subdomain

Simple bash script to create apache2 virtualhost for localhost. Can be used for public subdomains on developer server with changes - "replace .localhost". Tested on Ubuntu, but should work where ...
6
votes
1answer
379 views

Function to get specified key from /proc/cpuinfo

On Linux, the file /proc/cpuinfo returns a set of key-value pairs, where the key and value are separated by a colon and each pair has its own line. It's a bit more ...
6
votes
1answer
76 views

Pseudoportable C script pattern

(See the next iteration.) From time to time, while working with a command line in *nix family of operating systems, we have to write those scripts doing a rather specific task. Usually we use ...
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 ...
6
votes
2answers
190 views

Bash log monitoring

I've made a Bash script to monitor some server log files for certain data and my method probably isn't the most efficient. One section specifically bugs me is that I have to write a newline to the ...
6
votes
2answers
281 views

Printing a directory's contents in a loop

I wrote a bash script to print contents of files in a given directory in a loop. How can I improve command line parameters handling to the script? I feel the parameter processing as of now uses too ...
6
votes
3answers
287 views

Symlinking shared libraries from a platform-specific directory

We have a setup script for setting up a development environment, and setting up the image libraries is getting a bit messy: ...
6
votes
2answers
849 views

Loading records from an XML file into SQLite

I have a script and I need to optimize it to reduce the execution time of this, currently, 6000 lines takes 1 minute and 38 seconds, I would like to reduce the time to take much less and I do not know ...
6
votes
1answer
112 views

Bash command helper in C++

I'm writing a program to help with remembering complex bash commands. On invoking the program, it asks for a description of the desired operation, e.g., "increase volume" or "find orphaned packages", ...
6
votes
1answer
90 views

Monitor Downloads folder and sort files as they are downloaded

I have written my first shell script that uses inotify-tools to monitor my Downloads directory. What I intend to do with the script is that, as soon as a file is ...
6
votes
1answer
220 views

Building/installing bash script

I'm writing a bash script that has these goals: to build a node program from sources to install the built program on Ubuntu Linux to allow the user to rebuilt from most recent sources to add a small ...
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 ...
6
votes
1answer
126 views

Get bibtex entries from metadata of PDF files

When I have to write a report or an article, I usually have my bibliography as PDFs in a specific folder, so I wrote this script to automate the generation of bibtex entries. It works so far, but I'd ...
6
votes
1answer
68 views

Extracting Linux configuration information using Bash and Perl

For few days I'm thinking about making my code faster and using less CPU. This code is a statusbar that runs in a loop. I'm asking because there's a lot of perl and I'm wondering if it could be done ...
6
votes
1answer
702 views

Coloured bash prompt including git status and previous exit code

I wanted to create a short, informational and colourful prompt. My prompt includes: Exit status of last command (if not 0) Distinctive changes when root rsync-...
6
votes
3answers
307 views

Bash script to extract HTML comment into a Markdown file

I learned Bash a million years ago. I just wrote this simple script used to get the first lot of HTML comments from a file, and spit it out in order to create a ...
6
votes
2answers
85 views

OS testing script

This is a script I made for testing a simple operating system. It assembles the source and creates a boot image, then It automates the configuration of a Virtual Box machine. ...
6
votes
1answer
74 views

All-core MediaWiki website upgrade script

I wrote the following Bash script to upgrade All-core MediaWiki websites (no added extensions/skins or images - besides logo image). I already tested the essence of this script and it worked for me; ...
6
votes
2answers
257 views

Yet another bash backup script, using rsync --link-dest

I’ve written this bash backup script. It uses the --link-dest option of rsync; that way, the user have access to the backed data ...
6
votes
3answers
90 views

Checking and converting [[HH:]MM:]SS input format

I would like to use the following routine in my job submission bash script which expects the allowed walltime in the format [[HH:]MM:]SS. (Brackets indicating ...
6
votes
1answer
48 views

Small app to show variables declared in a bash script

This code and updates are available on Github. I've written a small utility to dump the variables that are assigned in a bash script. Please note: This script depends on the shfmt and jq apps. I am ...
6
votes
1answer
361 views

Updating my package version using only a Makefile

So I have written a Makefile that has a release function that can be run like: make release bump=patch and I want it to be fully ...
6
votes
2answers
446 views

A shell script to mount a disk image file

I'm trying to create a bash shell script which mounts a disk image file. Not only that but checks to see if the disk image already exists. Is there anyway I could improve my script? Currently my ...
6
votes
1answer
80 views

Script to download sequentially named files, rename them, and delete smaller files

I've written a little script to download sequentially named files, rename them, and delete files smaller than an certain number of kilobytes. I came up with this but I'm not too happy. Any advice for ...
6
votes
1answer
287 views

Git tag release build files and reset to commit without

This is part of a library that wants to release builded files (eg dist/*) when published to npm and bower. However, I don't want to commit those builded files for ...
6
votes
1answer
172 views

Copying files as fast as possible

I am running my shell script on machineA which copies the files from machineB and machineC ...
6
votes
1answer
115 views

Bash script to convert NIST vectors to debug scripts

TL;DR: The Bash script converts a published, somewhat-structured text file into a format usable by my testing infrastructure. It's slow, I think it's ugly -- although it is fully functional. The NIST ...
5
votes
2answers
588 views

Cleanup and server restart script

I have written a simple script for managing our Tomcat and Apache instances for deployment. What this script basically does is, when called, it copies the ROOT.war ...
5
votes
2answers
2k views

Fahrenheit / Celsius temperature converter

This is a simple bash script (hopefully with a little style as well) for converting temperatures from Fahrenheit to Celsius and vice versa. ...
5
votes
3answers
87 views

To print asterisks based on inputs

I have to print the number of stars that increases on each line from the minimum number until it reaches the maximum number, and then decreases until it goes back to the minimum number. After printing ...
5
votes
2answers
446 views

Bash “Rotating” MySQL backup

I'm quite a novice in shell scripting so far, but i'm learning and getting quite comfortable in writing shell scripts, but i have a lot to learn. The snippet at the bottom of the page creates backups ...
5
votes
3answers
1k views

Validating a credit card number using Luhn's algorithm

I implemented Luhn's algorithm explained on Wikipedia to validate a credit card number, in Bash. Does this code follow good practices? ...
5
votes
2answers
260 views

Counting unique visitors in access log

I'm aware I am probably reinventing the wheel somewhat here, but I am trying to teach myself simple bash coding by completing simple tasks such as parsing files. To that end I am looking to learn ...
5
votes
2answers
120 views

A little bash function, assigning attributes

This function checks if an attribute has been passed and if not, asks user for input. I'm new in bash scripting and would like to get some feedback. Is it okay or should I refactor this code somehow ...
5
votes
1answer
242 views

Bash script to check available name in Github

I just wrote this script to check if the name (that has 2 characters: 1 alphabet and 1 number) in Github is available or not so I can accompany this name. Here is my script: ...
5
votes
2answers
54 views

Install, configure, and maintain content for Ubuntu webserver

I made a script for my Ubuntu server(s) running on Google Cloud Platform. The idea behind it is I can create a new instance and paste this script in Google Cloud so it runs it on the new instance and ...
5
votes
2answers
112 views

File handling script

This is my first bash script so I ask to you to say what you think. The script must check every directory and if it finds a pdf file in this directory: move all the pdf files to parent directory, ...
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 ...
5
votes
1answer
77 views

Bash function that allows running user aliases with sudo on Ubuntu

I wrote this little Bash function to replace my sudo command. It checks whether I have an alias for the given command and runs the aliased command instead of the ...