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.
616
questions
4
votes
1answer
351 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
94 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
70 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 ...
6
votes
2answers
885 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 ...
1
vote
1answer
50 views
Bash time converter
This is a simple script to convert a given unit of time to other units of time. I wrote this mainly to practice writing scripts that incorporate positional parameters. It actually turned out better ...
5
votes
1answer
83 views
Optimize and accelerate bash script to transform XML to SQLITE
I have this script in which I read an XML and I pass it to CSV and at the end of the script I transform it into SQLITE
...
6
votes
2answers
664 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 ...
2
votes
1answer
112 views
Init.d script for Rails managing a Rails app via Unicorn
This script is to enable the remote management of a Rails app via one script.
I pieced it together from various blog posts. I am not to familiar with some of the BASH functionality that is used. It ...
3
votes
1answer
720 views
bash script - sed - template file processing
Using a bash script to process a file and pass it to AWS CLI. The script runs inside a docker container.
I'm using sed to do template string replace. When MY_VALUE ...
6
votes
5answers
270 views
Convert FLAC files to MP3 in parallel on Ubuntu
I created a script to convert my FLAC music collection to MP3. I did this so that I can play the MP3 files in my car, as the integrated head unit only supports MP3 and WMA files. The script works on ...
13
votes
2answers
188 views
Flac Converter And Organizer
I really like flac files, but my phone can't store them all. So I made a script for converting them, that slowly became a full featured flac organizer. I'd like to improve my programming skills, as ...
8
votes
3answers
440 views
PS1 for Bash prompt showing last exit status, written mostly in Python
I had most of this functionality accomplished in BASH, but I was having trouble getting the last process's return value (even though I had a minimal working example). Plus, the escape codes made ...
3
votes
1answer
62 views
Don't MiTM me please
To first understand how MiTM works I've made a few MiTM scripts, but this time I wanted to defend myself against such attacks. I'm unsure if my idea even works. The code seems to be working but I make ...
1
vote
2answers
116 views
Finding the second highest version using bash array script and clean up files
The goal is to print the highest version and second highest version of the list of files. The version is based on the first three digit places of the version. For example, version 2.3.0.1 version is ...
3
votes
1answer
170 views
Passphrase generator script
Below script is used to generate passphrases for gpg (or anything really).
Do you see any blatant security mistakes in it?
I wrote it by myself, because I couldn't find any passphrase generator that ...
3
votes
0answers
22 views
Compare timestamps of svgs versus exported pngs and export via Inkscape
This script goes through all svg files in an assets folder and compares them to the exported layers (one level above). If the svg timestamp is newer, it will automatically export the svg using ...
1
vote
2answers
52 views
BASH correct usage of single/double quotes when writing variables to file
(running Ubuntu 16.04.3)
I created small script with tasks I do every time I upgrade/change Ubuntu version. One of the tasks is to write script to file, this is actual written file:
...
2
votes
0answers
110 views
Read file real time with while loop and trigger action on change
I want to read a file real time with a while loop that is being fed by the stdout of a process (inotifywait). The output could ...
4
votes
0answers
137 views
Bash script to symlink configuration files from git repo into home directory
My goals are to:
Do it automatically (without adding a line to my script every time I add or change the location of a config file)
The files in the git repo folder should not be hidden, but the ...
2
votes
1answer
89 views
Extracting large tar.bz2 folders in parallel
The bash below utilizes parallel to extract tar.bz2 folders with 9 files in them. The total size of each is around 60GB. Below ...
2
votes
2answers
44 views
bash input parameter logic
The following works fine and I'm not having to repeat any commands once logic is evaluated. However, it feels as though I'm doing a lot of seperate checks. I'm wondering if I could do this more ...
1
vote
2answers
127 views
Dockerfile for Laravel deployment
I'm looking for reviews about my first dockfile. I don't want to develop bad habits.
The purpose is to quickly deploy my Laravel (5.4) application. I'm going to connect it with others database ...
3
votes
2answers
126 views
Authenticating to Amazon EC2 Container Registry
New to bash. The script I wrote works, but I don't believe it is written in the best way possible.
The script only assesses how to execute the aws ecr get-login ...
2
votes
1answer
126 views
Batch bash installer script for clean Ubuntu GNOME installation
I just finished (I think) writing a bash script to install all my essential software to Ubuntu GNOME. I'll be making more for different distributions but once I have one to go off of, I can do the ...
5
votes
2answers
143 views
Safe (and restricted) version of eval
I have built a shell function aimed to perform the following:
Given a string as first argument, perform safe expansions (i.e. those that cannot cause arbitrary code execution and only produce string ...
4
votes
1answer
109 views
Bash manual page selection menu (version 3)
This is an interactive script for selecting and reading the manual pages from the terminal command line. This is the 3rd version of this script. If you want to see the evolution of this script, follow ...
7
votes
1answer
853 views
Automated owncloud installation script
Here is a shell script which installs and configure owncloud on a Debian server. It also installs apache2 and MySQL as dependencies and fail2ban with a specific rule for owncloud. Apache2 is also ...
3
votes
1answer
36 views
Bash functions to modify PATH
I am working on improving my bash environment. I have added the following function to my ~/.bashrc in order to facilitate modifying my PATH as well as removing ...
8
votes
3answers
1k views
Bash: change git remote from SSH to HTTPS within a given dir
The code takes a user input dir path, then looks for git remote url that is still using SSH, and the repo is belong to an fixed Organisation. Then it will convert these repos' git remote url from SSH ...
12
votes
2answers
3k views
Bob Marley is jamming on the wifi
Bob is jamming it's way through the city deauthenticating people from thier wifi for a few seconds. First scanning all possible wifi-AP and then pretty printing them, afterwards you can choose a wifi ...
4
votes
1answer
28 views
Alternative to env that accepts arguments
It is commonly known that env does not allow passing of arguments - at least not reliably. There are various workarounds described here, but they felt to hacky and ...
3
votes
1answer
81 views
Bash script to run development tasks for configured projects
I wrote this script template at work to save typing repetitive commands and to improve my Bash-fu. I'd like to know of any moderate-to-severe quoting, robustness, security or usability issue. All code ...
4
votes
2answers
176 views
Sign an EC2/S3 URL
The other day I found myself trying to walk through the instructions for signing an S3 URL.
http://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html
Not as trivial as the ...
7
votes
3answers
2k views
Getting the current IP from the command line
I made a tiny little bash script, that prints the current IP Address to the command line. I checked the script with ShellCheck (0.4.6-1) on a local debian install and I get the following message:
...
3
votes
2answers
73 views
Enable or disable sections of a model according to user input
I am using sed command to comment in or out sections in my model according to user input (commenting is done by prefixing the line with !). Once this is done, I ...
3
votes
1answer
525 views
Install Ruby using rbenv in a bash script
I want to write an automated bash script for installing Ruby and Rails using rbenv, but I am getting session reload issues in the terminal.
...
4
votes
1answer
57 views
Gentoo ebuild for CUPS to support Kyocera 1x2x MFP printers
Let me be the first one to post a Gentoo ebuild for review, as suggested by this meta post answer and comments. See also the corresponding issue on Gentoo Bugzilla.
The ebuild installs proprietary ...
4
votes
1answer
43 views
Remove every line that include and follows the second occurrence of a given pattern
From a file, I am trying to remove every line that include and follows the second occurrence of a given pattern in Bash (Mac OSX). Note, that a file may have only one match of the given pattern (and ...
5
votes
1answer
1k views
Bash script for referencing git status output files
Whenever I do git status, I want to reference the files that were shown easily... whether it be so I can open it in vim, git add it, delete it, git checkout (to ...
2
votes
1answer
236 views
Bash - script to encrypt pdf files using pdfencrypt
I wrote a small script to get around the issue when using pdfencrypt on the command line the password is always echoed as well as being saved to the 'history'.
<...
3
votes
1answer
534 views
Bash script to deploy a mongodb cluster on local machine
I recently wrote a small script to deploy a mongodb cluster on a single machine.
The cluster is composed of :
3 configurations server that holds the same informations (they are replicas )
2 shard ...
5
votes
2answers
68 views
Pseudoportable C script pattern - follow-up
See the initial/previous iteration.
I have rewritten the script following the answer of @200_success.
Now it looks like this:
...
2
votes
1answer
111 views
Basic Nginx server environment creation script
Here's a script I wrote for raising up a basic Nginx server environment.
The script includes an internal script named csb (create Sblock) which is used to create Sblocks in a comfortable way. As I'm ...
2
votes
1answer
53 views
Generates a bare git repo from existing one and copy it to a central server
This is a Bash script that takes the name of a local Git repo and a remote server host/path, generates a bare repo, and copies the bare repo to a Git server located in another server.
Example usage:
...
3
votes
1answer
172 views
Loop for input section of rename script
For the input section of a script, I wrote a snippet using a while loop and an if statement to check whether there are matches ...
4
votes
1answer
119 views
Bash Script - batch rename files in current directory with preview
I have written the following script to automate my frequent usage of rename.
This saves me from always typing the whole command to the command line as well as doing ...
3
votes
3answers
86 views
Shell script to rebuild a Java webapp
I am asking for an experienced person to review my basic shell script. I do not write them at work, but I am a software developer. I am using this for my personal project that I am working on. Later, ...
8
votes
3answers
401 views
Update MediaWiki settings with dynamic IP address
I'm running a MediaWiki instance from a home server where the public IP address is not guaranteed to remain static. The following script is meant to run at boot time to check if the IP address has ...