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
4
votes
2answers
395 views

Parsing Gaussian 09 output for energy statement on one or more files and reformat it to a table

I am a computational chemist working with the program Gaussian 09. After I manually check the output(s) I want to create a summary for easier processing of the obtained values. Also avoid opening all ...
4
votes
2answers
82 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 ...
4
votes
3answers
672 views

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

This checks if a font is installed by using fc-list and grep. If the particular font is not installed, it offers to install it ...
4
votes
2answers
5k views

Bash CGI Upload File

I'm using the following Bash CGI to upload a file: ...
4
votes
3answers
970 views

Loop through all virtualhost log files and run goaccess on each file

So I have multiple websites running under apache2 virtualhost - and I wanted to use GoAccess to process the access.log for each site. The directory structure is ...
4
votes
2answers
54 views

Automatic CRL files converter

In my job we use our internal CA, which runs on a Windows server. When I want to use its CRL on a Linux machine I have to do these steps: download root CA and intermediate CAs covert them to x509 ...
4
votes
2answers
83 views

Bash Database Backup to AWS S3

I've written a bash script that backs up databases and uploads the backups to an S3 bucket. I have the bucket configured to delete backups that are older than 90 days. Is there anything that can be ...
4
votes
1answer
1k views

Bash function to parse git status

I have a function here and wondered how well this can be refactored. I currently have this: ...
4
votes
2answers
300 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 ...
4
votes
2answers
350 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 ...
4
votes
2answers
81 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 it?...
4
votes
2answers
1k 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/ ...
4
votes
2answers
2k views

Checking percentage of free memory using top and awk

The following Awk code was created in order to verify if free memory from the top command is less than 20% of the total. I've noticed that I actually do not need the ...
4
votes
3answers
206 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. ...
4
votes
2answers
269 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
1k views

Bash script that can uncompress: tar, gzip, rar

This code generally works exactly as it is supposed to. I'm learning bash I'm looking for some constructive help that could help me improve my work. ...
4
votes
2answers
462 views

Need some advice and feedback on my C code calling Bash functions

My intent is to use Bash functions defined in functions.sh in a C program. I am doing this so that I don't have to rewrite the Bash functionality again in C. I want ...
4
votes
2answers
44 views

Simple media ingest script

Trying to script a simple command line tool for ingesting media to a target location following a structured naming convention. It's functional in its current state but I'd like to know if there are ...
4
votes
1answer
53 views

Script to clean up old files that should only run one instance

I'm writing a bash script for deleting old files on a Linux server. Here are some relevant facts about this script: As currently written, it does work as expected. However, it's entirely possible ...
4
votes
1answer
462 views

Bash script to replace string in database

How secure is my script? ...
4
votes
1answer
327 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 ...
4
votes
1answer
42 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 ...
4
votes
2answers
282 views

Bash script for setting up a LAN to WLAN router

I wrote a bash script for the Raspberry Pi 3 (Raspbian) which has the main task of setting up a LAN to WLAN router. In addition it makes some things nicer for the intended users who have Windows ...
4
votes
2answers
108 views

MacPorts - Quick Install Script

I wrote this script to automatically install the relevant version of MacPorts. It's supposed to be used in a fashion similar to the official installer for HomeBrew. FYI: The real reason that I ...
4
votes
2answers
149 views

Build script for an operating system written in C++

I recently started following the James M Kernel Dev tutorials and was able to create an operating system in C++. Here is the source on GitHub. I have a couple of questions: Is my coding style ok? ...
4
votes
2answers
466 views

CGI script for managing Unix passwords

All the services I run on my server are based on Unix accounts. Since most web services have their own users and perform all the account management separate from the actual system accounts, I created ...
4
votes
2answers
275 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, ...
4
votes
1answer
876 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 ...
4
votes
2answers
261 views

Reading options from .cfg file

I have a bash script that reads a config file with key/value pairs and uses these values to modify the functioning of other scripts correspondingly. Example .cfg file: ...
4
votes
2answers
68 views

Upload a directory, in parallel, to an artifact repository

This code uploads an entire directory and allows for its reparenting on a remote server (an artifact repository). Three concerns: Copying the files locally takes a lot of space. Ideally, I could use ...
4
votes
1answer
69 views

Select second field in text table with shell script

I am writing a bash script to mount openshift service accounts into kubernetes objects. The right secret to use is highlighted in this text: $ oc describe sa sa-...
4
votes
2answers
61 views

Serial copying from disk images to folder in Bash

This is a Bash script that copies files stored inside disk images to a directory, using a defined structure provided via a JSON file. I've included the external programs it requires and the test I ...
4
votes
2answers
55 views

CGI for htpasswd registration

I decided to go with a very simple CGI user registration program to pair with Apache's mod_auth_form wrapper around a private site. It was only just after I ...
4
votes
2answers
71 views

Finding domain details with bash

Here is my code to find the details of the domain. The domain can be feed as following: ...
4
votes
2answers
31 views

Isolate URLs from other text around it and put each on own line (with sed)

I have a small shell script that uses sed to take an input file of URLs with hand-written notes around them and strips the notes and puts each URL on its own line. ...
4
votes
1answer
224 views

A little advanced mouse clicker in Bash for Linux

My today's goal was to create a little advanced mouse clicker in Bash for Linux powered by xdotool. This clicker implements 15 pixel random range in which it clicks ...
4
votes
2answers
339 views

Sorting a file with three-line blocks by the second word of the first line in each block

I have a text file with the following three line pattern with blank lines in between. My script sorts alphabetically by each person's last name and preserves formatting. I would love to see other ...
4
votes
3answers
103 views

Un*x terminal history wiper

Using various answers from Stack Overflow and Ask Ubuntu, I've hacked together this simple C program that wipes terminal history. It works but I'm relatively new to C so I'm not sure if everything is ...
4
votes
2answers
281 views

Dockerfile to install Apache

I'm getting started with Docker, and I've set up a very simple image built from a Dockerfile. It's based FROM the ubuntu image, ...
4
votes
2answers
319 views

Script to generate templated PHP code

I've created a script to create a module in our MVC framework. The structure of the module is like this (for this example, the module is called test): ...
4
votes
2answers
95 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 ...
4
votes
1answer
2k views

Setting global environment vars from Python or Bash

...
4
votes
2answers
96 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 ...
4
votes
1answer
135 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 ...
4
votes
2answers
4k views

Bash script to send to recycle bin or trash

This is a script that emulates a recycle bin in the CLI. You can undo your last changes and delete files This is my first bash script so don't hesitate to bash me. Thank you for taking a look. <...
4
votes
3answers
69 views

Write bootable image to USB device

Recently, I've been making and refining installer and rescue images to boot from USB media, in the form of CD-ROM or hard disk images. After a few occasions where I re-ran the command after removing ...
4
votes
2answers
240 views

Generate SQL UPDATE from Excel CSV file

I must write updates in a database from a flat file (CSV). I want to do that in the shell, with tools such as AWK. ...
4
votes
1answer
293 views

Watch log dir for new file, automatically tail to slack

We have a process that outputs to log files in the format /var/log/xxx/YYYY_MM_DD.log - the file name is chosen programmatically and is not rotated using logrotate ...
4
votes
1answer
1k views

Simple load testing script in bash

Here's the code ...
4
votes
1answer
79 views

Search and merge split-archive backup parts

I wrote some code which searches parts of a split-archive backup (it's an Android backup, I used flashfire to backup) and rejoins them. As you can easily see, I've achieved this by ...