BASH is the Bourne Again SHell, the successor to the classic Unix sh (shell). It's the official shell of GNU.
4
votes
3answers
91 views
Git script that fast forward merges and deletes the old branch
This script fast forward merges a branch and then deletes the old one. I normally run it like this:
git m master feature
Here's a link to the gist.
...
3
votes
0answers
16 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.
...
0
votes
1answer
16 views
Small bash script to start and stop named services
I've been working on ubuntu since many years but not quite familiar with bash scripting. My development tools involve servers like nginx and apache, the mysql database and beanstalkd. Obviously, I ...
4
votes
2answers
35 views
Filter shell script to find lines that contain all specified patterns
I wrote a script that does the following:
Run another script on the system
Filter the output to find lines that contain ALL of the given patterns
Pipe the output to a second script on the system
I ...
2
votes
1answer
18 views
Trash Filing System
This is a script (function) to be added to a bashrc. The purpose is to not actually remove files, but rather to send them to a trash folder for safe keeping. I was tired of deleting important files. ...
2
votes
1answer
23 views
IPtables for webserver with ssh
I've had a bit of help but I'm still a bit unsure. I have an nginx webserver with SSH only required. I wrote this rule set based on information I found on the internet:
...
0
votes
0answers
21 views
Pre-commit hook modifies AssemblyInfo [migrated]
I have a pre-commit hook that defines the build number using ruby gem semver2. The gem basically just creates a file called .semver that stores the version info for the package. I have a few questions ...
0
votes
2answers
12 views
${} shell substitution using output of another program [closed]
I want to collect total RSS used by all foo processes and pass it to quux script as an argument.
...
5
votes
1answer
63 views
Building/installing BASH script - does it need major changes?
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 ...
2
votes
1answer
32 views
Grep to search for array of location targets
Please review my short 65 lines of code:
Is there a way to avoid eval (security)?
Is there a better way or place to use ...
1
vote
1answer
50 views
Comparing if-else and case condition
I have a script used for installing few rpms depending on operating system type. Here in this example, the script will install packages on two system "centos" and "suse". The system names are listed ...
0
votes
0answers
43 views
Script to configure accounts, SSHD, and firewall [closed]
In terms of general security, am I doing anything wrong in this script?
...
3
votes
0answers
107 views
Is there a better way to copy into two different folders on a machine simultaneously?
I am trying to copy files from machineB and machineC into machineA as I am running my below ...
3
votes
0answers
63 views
Bash Music Player 2
This post is a follow-up to this.
I wanted further reviews since the code I provided became too old when I got replies, which is why I'm providing it again here.
I'm hoping I could get reviews for ...
4
votes
1answer
62 views
Shortcut script for elusive grep command
This is an example of my filesystem:
/code/
internal/
dev/
main/
public/
dev/
main/
release/
tools/
/code/internal/dev/, /code/public/dev/ and /code/tools/ contain subdirectories for ...
3
votes
0answers
73 views
How to copy files as fast as possible?
I am running my shell script on machineA which copies the files from machineB and machineC ...
3
votes
1answer
97 views
Bash Music Player
I have finally finished creating my first real project. It's just a simple music player that can provides the user with the latest music from any site (as long as it contains MP3 files) he provides ...
7
votes
0answers
129 views
Bash script to clone all public repos or gists for a specified user, optionally to a directory of choice
I wrote this script as a way to backup and/or download quickly a set of repos or gists from a user. I don't have any major concerns but I'm a noob at bash scripting, and I've been scouring the ...
6
votes
1answer
51 views
Bash script to convert NIST vectors to debug scripts
TL;DR: The Bash script (below) is converting 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 ...
6
votes
3answers
60 views
Encrypt and backup folder to email daily, when online
I have a backup script which should backup a folder and send it to email. This should be done once a day. As this is on my laptop which is not online 24/7 I need to check that I am online and can send ...
0
votes
1answer
40 views
3
votes
1answer
100 views
0
votes
1answer
48 views
Is my makefile correct? [closed]
I am new to using makefile. I have got three files in a folder- cat.c, hello.c and bash. I am not sure if this is the right way to do it.
...
9
votes
2answers
94 views
Bash script to clear files not matching a given extension
Using LaTeX creates a bunch of auxiliary files like foo.aux, foo.log, etc. Sometimes, I want to create a clean run of my ...
7
votes
1answer
75 views
Script for handling PPA's on Ubuntu
I'm writing a bash script to handle the PPA's on Ubuntu & derivatives. I was wondering how to know if I'm handling this the right way.
So, the script works (flawlessly), but I posted it to a ...
2
votes
2answers
42 views
Is this an appropriate approach and layout for conditionally continuing execution in bash?
I've seen others use && for conditionally continuing execution in bash, and found it effective but rather ugly. (I'm not sure if there's a better name for this technique.)
...
2
votes
1answer
85 views
Bash pass multiple commands to SSH and make readable
I have a script that sends multiple commands after logging in a remote machine via SSH.
Problem is, it's barely readable. I've tried quoting everything with "", but it's terrible (everything appears ...
8
votes
3answers
237 views
Bash script that updates Intel e1000e driver
I am now writing a small bash script that updates an Intel NIC driver to the latest version from the official website. Is there any way to improve\simplify the script? I want to avoid a lot of ...
7
votes
1answer
107 views
Bash script - automate an upload image + description process on a server
I was tasked at work to improve a system where through a web interface a client, which eventually became us, uploads a bunch of images with descriptions (latter coming from csv files), the images are ...
5
votes
2answers
197 views
Text snippet creator/manager in Bash
Below is a script to create and manage text snippets. It is also posted on GitHub. Most of the code is error checking and displaying help because I wanted to make a solid command line interface. The ...
5
votes
2answers
628 views
Running a shell command and getting output
This is the code I'm currently using to run a shell command on the current machine, intended for use only with GNU/Linux at the moment:
...
8
votes
1answer
153 views
Connecting to EC2 instances using the instance name instead of IP
I'm an intensive user of AWS EC2 instances, many instances are launched, stopped, repurposed, etc.
To connect to any instance using SSH I must keep track of their ...
2
votes
1answer
86 views
Ruby install script; packages+installs as a .deb or .rpm from source?
I have a variety of scripts of this form:
...
10
votes
1answer
86 views
Locating matching files with input folder and file prefix
This is my first more-than-1-line script. It takes an input folder and a file prefix and gets all the matching files. For the first of the files, the script grabs the first line and appends an extra ...
1
vote
1answer
127 views
Interactive menu system in Bash [closed]
This is a simple loop menu script that I have for class. The goal was to make a menu with applicable commands.
Menu:
A. Greet me. (Greet the user by their username (using the whoami ...
3
votes
2answers
84 views
Mixing function parameters, commands and command arguments in Bash functions
I'm trying to write a bash function that will take a command such as xcode-select -v or brew -v that outputs a lot of extra ...
1
vote
2answers
61 views
Managing while loop in bash
Two difference scenario in bash program,
First
Here i am breaking loop in function testFunc.
...
3
votes
2answers
78 views
Parallelizing upload
I needed smth that could send (scp/rsync) many files in parallel but that would not overload machine, firewalls on the way by starting e.g. 600 simultaneous uploads, so upload should be done in ...
4
votes
2answers
79 views
Is there a 'better' way to find files from a list in a directory tree
I have created a list of files using find, foundlist.lst.
The find command is simply ...
2
votes
1answer
120 views
Bash script to monitor Webserver php script
Below is a script I wrote today to use CURL to monitor the length of various HTTP server outputs and output a response if this is different than 103 characters.
This is my first bash script, so I had ...
1
vote
1answer
142 views
Spell check interview problem in Bash
Thanks for taking the time to read this.
I submitted a code screening for a company I really wanted to work for and spent a decent amount of time on their programming assignment. Pretty bummed when ...
4
votes
4answers
65 views
apt alternative for proxy environment with bash shell
As I am new to bash scripting, and want to use apt-get in my university. I know that many people have issues when trying to do so. My focus is simplicity and ease of use, but still need to be ...
2
votes
1answer
194 views
Bash to find all placeholder variables in a file and replace will real variables
I am looking to make a generic config file using variables such as:
$PLACEHOLDER_USER
Then after moving the file into the correct position I want to replace every instance of *$PLACEHOLDER_VARIABLE* ...
2
votes
1answer
703 views
Send email if URL is down for 2 times only - bash shell script
we want to check if URL is down or not. But sometimes, environment is down for maintenance for 3-4 hours and we dont want to keep sending emails during that time.
I have written a shell script for ...
1
vote
2answers
111 views
Floating-Point data input in Bash and C
I wrote a function that dynamically stores statistical data. I tried to clone the functionality of how I had originally written my solution in Bash. Is there perhaps something I could improve, or do ...
3
votes
0answers
110 views
Project Bashory - Bash History
In effort to be more effective and productive with terminals I have started building a bash script. It is for handling the bash history of concurrently running terminals, archiving old commands, and ...
2
votes
1answer
75 views
cpupower bash completion script
I wrote a bash completion script for the cpupower command but I feel that it sucks, it's too long for such a simple task and have too much case/if-else nesting.
It supports all the subcommands of ...
2
votes
1answer
198 views
Bash script to set up an ad hoc wireless network
This script creates an adhoc network using hostapd.
I have tested it and seems to work reliably.
I am new to linux networking and not sure if this is a recommended way to create an adhoc network this ...
4
votes
1answer
155 views
New svn repository script
This is my very first Bash script that does something real. I'm here to learn, so please tell me if and how this can be done better.
...
3
votes
2answers
222 views
Automating easy-rsa cert creation with Bash script
In order to make cert creation with easy-rsa as practical for others, this script was created and it works so far. The questions are:
where can it be improved?
are there flaws that are not obvious ...