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
3
votes
1answer
130 views

Cyclomatic complexity script

As part of my programming training, I was told to research metrics for programming. I went ahead and turned the metrics into code starting with the cyclomatic complexity by McCabe. It works for bash ...
8
votes
4answers
193 views

Project Euler 1 - Multiples of 3 and 5 by Loki

Multiples of 3 and 5 Multiples of 3 and 5 Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. ...
2
votes
2answers
68 views

Bash script, “flash cards” for Spanish vocabulary

I use this bash script to review over vocabulary with my dental Spanish class. The script works great for me. However, I am wondering what other ways the same thing could be done. How could it be more ...
7
votes
2answers
217 views

Script to temporarily drop admin privileges

Description The aim of my project is to allow administrators to drop privileges for reasons of self-control. Currently, it works only on MacOS Sierra but the concept should be extensible to any Unix ...
3
votes
1answer
66 views

Query database and check server details

I have written bash script to query database and check server details. Please let me know if the script is as per best standards: ...
5
votes
2answers
96 views

Generate XKCD passwords from single Bash line

There are a few "XKCD password" generators out there, but the task seems so straight forward, so I wanted a compact and simple solution. My requirements were: One-line alias (or few-line function) to ...
4
votes
1answer
68 views

Try every option for a command and make anagrams out of the successful ones

What I have: I am trying to find what words you can make out of Linux command options like ls -cat or ps -elf. To do that I am ...
1
vote
1answer
125 views

Bash script that creates a local environment for CHICKEN scheme (like virtualenv for Python)

Usage To create a localenv called sicp, do $ localenv sicp Activate the localenv: $ . sicp/bin/activate Check installed eggs in ...
4
votes
2answers
58 views

Create and open a file to take lecture notes depending on day and time

I am just wondering what, if any, more elegant ways might exist to write a script to accomplish the task that the script below accomplishes. The script works, so I don't need it to be debugged, but I ...
7
votes
1answer
68 views

Make my set proxy script better

Below is my bash script to setup a proxy, I am by no means an expert in bash. I suspect there is a better way to write this, any tips would be appreciated. Is there a better way to do nested while-...
7
votes
1answer
96 views

Git pie - Perl oneliner for Git

I often make changes on my code-base and manually using sed, awk or perl -pi -e is not ...
3
votes
1answer
39 views

Concat downloaded content by wget

I want to get the latest release of certain package. In order to do so I did this: ...
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 ...
3
votes
1answer
84 views

Bash menu-driven text file viewer / presenter tool

This is a simple Bash script to provide menu driven manuals and standard operating procedures. Sops and mans with the extension .sopman.txt will be loaded. The ...
3
votes
1answer
75 views

Generate a Jekyll blog post template using shell

I'm creating my first Bash script newpost.sh, which generates a Markdown file containing the metadata for a new blog post. This blog post will be hosted in a Jekyll ...
3
votes
2answers
90 views

Simple Command Line Password Manager

Kruptos is a simple tool that encrypts and decrypts the ~/.kruptos directory with the password that is stored in ...
3
votes
0answers
43 views

Bash manual page selection menu (version 2)

This is update to a previously asked question Bash manual page selection menu. This script generates a menu for the user to select which manual page he/she would like to read. ...
6
votes
2answers
407 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
2answers
90 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 ...
5
votes
1answer
80 views

trash script to alias rm

This script implements a command line level trashcan system. Designed to work around rm doing the bits needed to implement a trashcan system at command line level....
10
votes
1answer
254 views

Mass build and save of docker images

I would welcome feedback about this script to automate the building of docker images from a set of dockerfiles. The dockerfiles are provided to the script via stdin. The images are saved to the ...
2
votes
0answers
87 views

Copy recently modified files from one directory to another

I am new to bash scripting. Could you please give a review of this code that copies recently modified files from one directory to another in bash? The main commands are in my ...
3
votes
1answer
44 views

Script to check for failed logins and then trawl users' .bash_history for keywords

I have created a script to check for failed logins and then trawl User .bash_history for keywords. There is also processing on the ...
1
vote
1answer
136 views

Checking the status of a ZFS pool

I'd like to see if there are any suggestions on how to improve a simple conditional test at the beginning of a backup script that verifies a ZFS volume is "online" and has the name "tank". For ...
3
votes
1answer
75 views

Showing all programs' man pages

I'm trying to discover useful command line tools in Arch Linux, and it seems one good way of going about that is to look through all of the man pages related to ...
5
votes
2answers
136 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 ...
2
votes
0answers
80 views

Chip-8 Emulator in Zsh

I've spent the last few weeks writing a Chip-8 emulator in zsh. It doesn't run in bash but the syntax is nearly identical. I have it on a GitHub repo here: https://github.com/hcorion/chipzsh a ...
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 ...
4
votes
1answer
552 views

Backup a SQLite database

I want to backup a single SQLite database daily up to 30 days back, but I also want to keep at least 2 backups at all times (i.e. if there have been no backups in the last 30 days because the database ...
6
votes
4answers
117 views

Nagios check to see if a certain IP appears in a trace route

I needed a test to know which firewall in out HA environment was currently active. We have a webFilter connected to our "primary" so if the firewall fails over the webfilter is taking out of path and ...
4
votes
1answer
225 views

Bash script prepares virtual environment

I have a few Flask projects that I want to install, each in their own virtual environment. The approach is derived from this tutorial. The steps to create the VE's are very similar, so they're easy to ...
3
votes
2answers
92 views

Bash script to rename subfolder to include name of parent folder

Here's the current structure of my directory. . ├── Show 1 │   ├── Season 1 │   └── Season 2 ├── Show 2    ├── Season 1     └── Season 2 I want to rename the ...
3
votes
1answer
154 views

BASH script to monitor subprocess and throttle it for CPU temperature control

I need to run CPU-intensive tasks on a very old machine with overheating issues. The script below will monitor temperature and pause the jobs when it gets too high, continuing them when it's back to ...
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
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
0answers
45 views

Selective Time Machine backup deletion

Time Machine is a useful backup service for Mac, but deleting multiple backups is cumbersome. This script allows mass deletion of unwanted backups while allowing specified "important" backups to ...
4
votes
1answer
70 views

Simple Bash Parallel Tool (env_parallel dies on big env)

This is a simple tool to parallelize execution of multiple tasks in Bash, since env_parallel can't handle the environment size (or something of the sort - dies for ...
8
votes
1answer
893 views

Guessing the JDK home directory

My project is using a specific version of JDK which is jdk-6 and the default JDK_HOME path will vary from distribution to distribution, so I wrote a script to guess it. Is there any way to do this ...
6
votes
1answer
118 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 ...
1
vote
2answers
161 views

Simple Linux upgrade script in Bash revision 2

As I will be deploying this script on multiple machines with the very same system Linux Mint 18 with rather same configuration, I would like to be semi-sure I won't screw things up much. This little ...
7
votes
1answer
3k views

Simple Linux upgrade script in Bash

As I will be deploying this script on multiple machines with the very same system Linux Mint 18 with rather same configuration, I would like to be semi-sure I won't screw things up much. This little ...
1
vote
1answer
48 views

Script to execute arbitrary command on each Git project in a directory

The idea is simple, most people have some one directory containing all their projects as subdirectories. When you are in the top directory and you run this script like so ...
4
votes
2answers
93 views

Optimize text search in files with Bash

I would like to get some performance improvement suggestions to a simple project I made using Bash in Linux. The target is to read all the *.desktop files, and ...
3
votes
1answer
73 views

ECG Bash selection tool

I made the following bash script for extracting a group of ECG signals from ECG files. I would like to know if there is any mistakes and/or weaknesses. I have experienced difficulties in integrating ...
1
vote
2answers
104 views

Excluding a long list of words with grep

This Bash program extracts the 20 first lines of each man page present on a system and uses grep to remove lines matching a list ...
3
votes
0answers
169 views

Daemonizing shell scripts - MqSH

This is an mqtt driven, interactive, and asynchronous remote shell daemon written in bash. I call it "MqSH" or simply "mq". It works with bash, the busybox ash shell, and perhaps other Bourne-like ...
3
votes
1answer
193 views

OpenVPN Authentication Script

I wrote a shell script to authenticate users connecting to an OpenVPN server. When a user attempts to connect, OpenVPN executes the script with the username and password variables sends. The script ...
5
votes
0answers
114 views

Semaphore implementation by file locking in a bash script

This implementation is inspired by the POSIX functions sem_wait() and sem_post(). It tries to get rid of busy loops in the code ...
5
votes
1answer
134 views

Game of Life Kata in Bash

I've implemented a Game of Life Kata with the aim to get to know Consul's K/V store. Although not the main purpose of the exercise, it would be nice if somebody reviewed some of the bash code in the ...
2
votes
2answers
181 views

Passing help options to a bash script

I used this code to give -h(help) options to my bash script. It's working fine and I wanted to get the code reviewed. ...