BASH is the Bourne Again SHell, the successor to the classic Unix sh (shell). It's the official shell of GNU.

learn more… | top users | synonyms

3
votes
2answers
250 views

forever.sh - should keep a process alive forever

This script's only responsibility is to keep a process alive. Forever. It's sole dependencies shall be bash and coreutils. I'm ...
8
votes
0answers
33 views

POSIX shell compatible and POSIX conforming dirname implementation

The discussion in the comments of this answer made me wonder how hard it would be to write a built-in only version of dirname. This is what I ended up with but I'm ...
2
votes
1answer
40 views

Hide/un-hide directory and open directory based on argument

This code checks to make sure a directory is hidden and if not hides it. Then if hidden it will prompt for password and if password matches it will un-hide it. There is also an argument to open ...
3
votes
2answers
30 views

Advanced CSV-to-SQLite converter

I just wrote an advanced CSV parser that translates CSV to SQL(SQLite Compatible) statements, which are then inserted into the database. It translates variable names in the CSV to values defined in ...
4
votes
1answer
40 views

Optimising script that does simple renaming of files

I have recently written some code in Bash where I'm starting to program some things and I think I'm overcomplicating the script I wrote. I'd like to make it simpler so that in future I would avoid ...
3
votes
1answer
30 views

GRE Tunnel Script

I've made this script above for GRE Tunnels and I'd like to know how I can improve it. Also, at the bottom, you'll see "Do you want to forward more ports." I want an easier method of asking this and ...
1
vote
1answer
15 views

Print first element of the last line of files when the second element does not match a pattern

I am relatively new to Bash, regular expression and stuff. In a directory, I need to read the last line of all the files that contain the word "fitness", and list (on one line and separated with ...
6
votes
1answer
37 views

Add license to beginning of files

I'm trying to come up with a script that will add license headers to certain files (depending on extension). My Bash is very average, so any guidance would be much appreciated. I'm not quite sure ...
4
votes
2answers
68 views

Who needs clean configuration? Swapping server.xml

So I'm working on a project that sometimes requires me to switch my server configuration. This is due to some circumstances with database drivers and names that are "too expensive to fix" ... That ...
8
votes
2answers
245 views

HTML Book Compiler

I have written a BASH script to parse and compile HTML code into a single page. The script works as expected, although my code is not completely re-usable and the standard output messages could be ...
2
votes
2answers
39 views

Simple Bash Music Player - follow-up

This question is a follow-up to this question. This is a year later, but it has the same context: I wanted new reviews for the updated code from the original question, but this time I wrote the code ...
8
votes
2answers
609 views

Fizz having an argument with Buzz

For my current project I need to validate responses. The requests will be send from multiple different shell scripts and should be controlled from another script. I'd never targeted a ...
8
votes
2answers
91 views

Fine tuning of an informative replacement for rm

I want to replace rm by a more informative variant: I would like to see which files will be deleted, along with their size, and I would like this information to use ...
6
votes
2answers
162 views

Address book app to learn bash

I'm fairly proficient in C and Python, but want to learn some skills for administrating my new Linux machine. I wrote this simple address book app to teach myself shell scripting. This is the first ...
4
votes
2answers
50 views

Bash script to replace substrings in a file with strings

I am an editor of the Funtoo Linux wiki and was looking to create a shell script that would help to ease the updating of pages on the wiki that use old tags by replacing certain deprecated tags with ...
3
votes
1answer
48 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
1answer
38 views

Bash script to backup from S3 to GC

I'm working on a script to backup S3 to GC everyday. I'm not sure if my script has any potential bug or error that might have destroyed anything from both sides? The data is quite sensitive and I ...
6
votes
2answers
136 views

Keep track of Terminal access

I am fairly new to bash (I have about 3 months of experience), and now I've written my first real application (sort of). It's a function inside of ~/.bash_profile, ...
7
votes
2answers
66 views

Text centering function in bash

I wanted to center some text in my commandline application, so I came up with this function. ...
10
votes
1answer
432 views

Calculating pi using bash

I've written a little program to calculate pi using the Nilakantha series: For this formula, take three and start alternating between adding and subtracting fractions with numerators of 4 and ...
8
votes
1answer
75 views

Bash script to remove unwanted git objects

A while ago, someone at our office thought it'd be a great idea to start tracking a number of fairly large binary files in one of our more important repositories. We noticed our builds were slowing ...
4
votes
1answer
50 views

Restart Services Automatically

I have been working on a script that automatically checks on the state of 2 services that I require to be running 24/7 on a server that I manage. The script works as I need, but I would really like ...
4
votes
2answers
81 views

Installing and removing kernel module RPMs

First, the script checks to see if it is installing two kernel module packages or removing them by looking at the first parameter. If no parameter is provided it complains and exits. If installing, ...
3
votes
1answer
53 views

Append the first half of the first line of /etc/hosts to a conf file

I have to edit a config automatically before starting a service in a docker container (a storm supervisor), and I want to append something like this in ...
12
votes
1answer
60 views

Load SSH key remotely

I often create new accounts or virtual machines, and then have to load my SSH public key/signature in to the authorized keys on that account. That process can be tedious, so I created this script that ...
2
votes
1answer
16 views

Bash Compress Managed Directory Ignoring .git, bower_components, node_modules, etc

Fairly easy way to compress a wordpress plugin (or similar) as a zip file without including all the dependencies used to create and manage the development, but which don't belong in the final product. ...
3
votes
2answers
30 views

Changing filename and copying in bash

I wrote a script which changes names of last downloaded songs and copy them to music directory. Can it be written better? ...
4
votes
3answers
63 views

Checking dates against a .properties file

I am writing a script that will check the set values against a .properties file and I am just wondering if there is any nicer way to write what I have here. ...
4
votes
1answer
128 views

Shell script that copies configuration and dotfiles to repository

A while ago I had the idea to store all the important configuration and dotfiles from my system in a Git repository. That saved me a few months ago: My harddrive died, but I could get back to work ...
1
vote
1answer
37 views

Alert on partition growth [closed]

I have a script that alerts me via email when a partition grows past a defined threshold in one hour. My script is run from cron hourly. Everything seems fine for 99% of the time, but occasionally I ...
2
votes
1answer
48 views

Bash menu for accessing network equipment

I wrote a menu in bash to access network equipment, but now there are too many of them to show in one screen to permit selecting one without scrolling up or down. I need it to be improved. I've ...
4
votes
3answers
77 views

Bash script that checks if font is installed and installs it if necessary

I'm new to writing bash scripts and I 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 font is installed by using ...
2
votes
1answer
29 views

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

I'm new to Code Review and new to writing bash scripts as well. I 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 ...
5
votes
2answers
63 views

SSH chatting tool

I have taught myself some bash and already knew some AppleScript, so I have come up with this SSH chatting tool for OS X users. It allows you to chat from a terminal to another OS X computer. One ...
2
votes
3answers
371 views

Unix shell function for adding directories to PATH

Adding a directory to the PATH in Unix/Linux is a very common task. However, what if the directory is already in the path? My goal is to write a shell function ...
2
votes
1answer
50 views

Website monitor - if site is down, kill the process, contact admin and restart server

My Python-based web server (Tornado module) is pretty complex and keeps going down (seems like usually in the middle of the night), so here's a bash script that kills the process, restarts and emails ...
3
votes
1answer
66 views

Compile and run C++ code

I have created this bash script for Compile And Run c++ code, car++.sh. As I'm new to bash scripting, I'm not sure about good bash programming practices. Please review it to see if you could find any ...
5
votes
1answer
145 views

Cleaning a WPA wordlist

I have a short bash script that processes gigs and gigs of data. I am looking for any improvements to make it faster. This is my very first bash script so please be gentle. I am really only ...
3
votes
1answer
38 views

Script to toggle touchpad

This sequence properly shows whether the TouchpadOff option for synclient is on or not (outputs either a ...
1
vote
1answer
40 views

Parsing logs in sed efficiently

I have an application which log file has most lines start with a time/date, followed by a debugging level and the actual log message. Often I want to watch the output live and colors make it a lot ...
5
votes
3answers
59 views

Alerting for rapid disk growth

I have a server that is pretty stable (disk capacity) until a certain event occurs and then the drive grows over the course of two days until it is full. I wrote a very simple bash script but I'm not ...
4
votes
1answer
32 views

Process files in all subdirectories and save output to new files based on their current path

Sample files: ./data/foo/file1.xml ./data/foo/bar/file2.xml ./data/baz/file3.xml Corresponding output: ...
3
votes
1answer
85 views

gcc installation script for Centos6.6

I have written this script to install gcc (here in version 4.9.2) on Centos6.6. I am only interested in C and C++ support. Please comment if this is any good and can I make it better before I get the ...
4
votes
2answers
137 views

bash script for constructing RNA pipeline

I have written a bash script that consists of multiple commands and Python scripts. The goal is to make a pipeline for detecting long non coding RNA from a certain input. Ultimately I would like to ...
3
votes
2answers
70 views

Producing recursive directory listings

This produces recursive directory listings(it's intended to do other things, so there will be something else instead of echo, but it isn't important), yet it isn't very intuitive. How can I improve ...
8
votes
1answer
635 views

Create New C++ Class

I'm currently developing a new version of ExpressGenGen Using TDD. While I'm rewriting the new version of my Code Generator Generator. I'm using its old version to generate code to be used by the new ...
1
vote
1answer
21 views

Backing up a server

I wrote a bash script to automatically backup a server and upload it to a server level FTP server. I'm somewhat new to the making of crontasks and other stuff heavily related to Linux administration. ...
4
votes
2answers
397 views

Bash script to send emails when web server does not respond

I've made a simple bash script to check if a web server responds, and to send emails to a list of addresses if the website is down. Any suggestions as to how to improve it/ edge cases that I missed/ ...
2
votes
1answer
193 views

Automating heap dumps from an Android device or emulator

I've automated the process of extracting and converting a heap dump from an Android device/emulator. I'd appreciate any feedback and improvements regarding style, bad practices, non-idiomatic code, ...
4
votes
2answers
374 views

Bash CGI Upload File

I'm using the following Bash CGI to upload a file: ...