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

2
votes
2answers
19 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 ...
0
votes
0answers
15 views

Building a Raspberry Pi network monitor. My code is not working [on hold]

A little background on me, I have 2 weeks of experience bash scripting on Solaris from a class about 2 and a half years ago, no python experience what so ever till this past Friday. I am a windows ...
3
votes
2answers
67 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 ...
7
votes
1answer
561 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
15 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
140 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
62 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
35 views

Bash CGI Upload File

I'm using the following Bash CGI to upload a file: ...
1
vote
2answers
27 views

Repeatedly fetching a URL until the response contains “state: INIT”

I am working on a project in which I need to make a URL call to one of my servers from a bash shell script. http://hostname.domain.com:8080/beat After hitting the above URL, I will be getting ...
2
votes
1answer
58 views

Sublime Text 2 R Build System (source file, send selection to interactive session)

The following is the description of the R build system I am using (very happy) with Sublime Text 2 on linux (Crunchbang). With it, I am able to: to source the current file.R to an interactive R ...
3
votes
2answers
66 views

Shell script to count chess game outcomes

I came across this blog post by Adam Drake from around a year ago which is now making the rounds again. I made some improvements to his code, but wish to see if there are additional tweaks that could ...
5
votes
2answers
38 views

Three “alias-functions” in my .bashrc file

These functions work well for me. Can they be improved or made more standard in some way? Each function has a documentation header block, which contains a description of what it does, along with ...
3
votes
1answer
69 views

Fast incremental backup algorithm using RSYNC

I'm running a simple Bash script that uses rsync to do an incremental backup of my web server every hour. What I'm looking for is an efficient algorithm to delete ...
4
votes
1answer
54 views

Two similar shell functions that run different programs

I have a script that contains two shell functions: ...
6
votes
2answers
121 views

Optimize bash script that concatenates output

I am trying to optimize my script that loops through a folder and extracts only the part of a file name before a date and the header of the file and outputs it into a different file using a delimiter. ...
4
votes
2answers
62 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: ...
14
votes
7answers
412 views

Extracting the classpath entries from a jar file's manifest

Sometimes I need to search for dependencies in the classpath entries in the manifest of jar files. A jar manifest with classpaths looks like this: ...
6
votes
1answer
47 views

Monitor Downloads folder and sort files as they are downloaded

I have written my first shell script that uses inotify-tools to monitor my Downloads directory. What I intend to do with the script is that, as soon as a file is ...
4
votes
3answers
59 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
55 views

Team git commit cleaner

I cleaned a big repository for my team with this Python code. My goal was for every developer in my team to check if some bad email are in the commit, and replace the information by the good one. I ...
3
votes
1answer
44 views

Changing cuts to sed for parsing dates from apache log (common log file)

Would switching my cuts below to SED improve performance? I am trying to get a per date count of requests for the last two weeks from a server log. The script runs, but slowly (comes in around 14 ...
0
votes
1answer
108 views

Is this iptables firewall bash script good? [closed]

I'm learning to use iptables to implement it in my company software. The goal is either to prevent the major attacks and to have good speed transferring files (ssh and ftp). Can you help me to improve ...
1
vote
1answer
42 views

Screen timeout/lock script

This is a script I made while having trouble with xautolock and dimming of the screen right before locking it. I would like some tips for making it a bit more robust and to know of any disadvantages ...
2
votes
1answer
122 views

Dovecot user add & delete bash script

I learn BASH scripting occasionally from time to time, now I am working on a simple bash script that serves to maintain dove-cot user database. The general purpose of the script is able to list, add ...
5
votes
1answer
55 views

Bash script for Git & VSS interop

I have been slowly evolving some code for Git and VSS interop based on a quest I started a while ago And the code is now working, some parts have been updated without test (such as the init) and I am ...
1
vote
1answer
68 views

Simple Bash backup script - follow-up

As a follow up to a previous question, linked here, I have revised the code and developed what I believe to be a better solution. In summary, the script should backup all files in a particular ...
3
votes
1answer
132 views

Simple Bash log backup script

I have developed the following script to zip and then remove all files with "*.log" extension in the file name that were modified yesterday. It's definitely not 100% at the moment. For example, it ...
4
votes
1answer
46 views

Rename files to all lowercase letters

I use this Bash script to rename specified files to all lowercase letters: ...
4
votes
3answers
192 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 ...
2
votes
1answer
33 views

Bash-based MySQL inventory scanner

I am trying to create a bash-based inventory scanner, and was wondering if there is anything 'glaringly' incorrect about my syntax or usage. I was hoping I could get some feedback on: bash ...
3
votes
1answer
50 views

Can this bash shell script that checks for rvm ruby versions be improved?

As it is going to be used as part of some automation and not just at the command line I was wondering if it could be improved at all. Improve would mean any of: handle sad cases better handle ...
8
votes
1answer
419 views

Securely delete a file

I am trying to write a script to securely delete a file. What I am intending to do is to pad the file with /dev/zero once, and then with /dev/urandom three times and then delete the file. For now the ...
2
votes
1answer
42 views

Bash script for reviewing .pdf articles

I wrote a bash script for reviewing scientific articles. It adds a blank page for notes and creates a new landscape file. I'm sure it can be made better code wise. Any suggestions? ...
3
votes
1answer
26 views

Renaming and moving files in a subdirectory with an index and the folder name

I'm putting together a script to take .mp4 files organized into folders that described the video (eg. cat) and I'd like to do the following: rename them with the folder name and a number move the ...
4
votes
1answer
59 views

Find-grep-sed for project-wide search & replace

I always forget how to do this efficiently with Vim's arglist. Drawing inspiration from a post over at Stack Overflow, I wrote a Bash function to perform a project-wide search & replace. It does ...
2
votes
1answer
46 views

Bash Script - File Comment out & Notate

I have been writing my own Bash Scripts for a little while now. I am getting a better comprehension of it and I would like to start refining my code to be more elegant. I have recently developed this ...
3
votes
1answer
54 views

Bash archiving script

I inherited a script at work the other day. I know very little about the command line in general but I'm not entirely new to programming. I am using this as an opportunity to learn... Very little ...
5
votes
1answer
58 views

An atexit for Bash

I wrote the following atexit implementation for Bash ...
4
votes
1answer
47 views

Unit testing a bash script manipulating the working directory path

bd is a bash script to conveniently jump multiple directory levels up from the current working directory instead of a tedious and possibly inaccurate ...
3
votes
2answers
236 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 ...
6
votes
3answers
133 views

Back up or restore home directory

I am currently trying to learn bash scripting and I've made a script that backs up or restores my home folder. My main question is whether my code is readable or very messy. I would love to learn to ...
6
votes
1answer
385 views

Bash script for getting geolocation (latitude, longitude and country code)

I have a bash script, where I need to get the user's geolocation (latitude, longitude and country code). If a GPS device is present, I use gpspipe. But a lot of laptops/computers don't have GPS ...
2
votes
1answer
37 views

Controller web interface security

I'm designing a web interface to a controller for my school's bell. Are there any security flaws in this code? The source code is available here. Front End: ...
5
votes
1answer
77 views

Updating an Nginx config file for SSL

This script updates a settings in ssl config file for Nginx. I generate DHEC key and then update the Nginx SSL file to that location. I also give an option for the user through arguments if they want ...
6
votes
5answers
236 views

Mounting multiple partitions on a disk

Is it possible to improve the code of this bash script? ... or should I just use another language? (If so, which one would fit the best the situation, according to you?) Here is the code (simplified, ...
2
votes
1answer
57 views

Bash script for tagging the current git workspace including uncommitted changes

I use the following script to autotag the current workspace while building even if there are changed (not committed) files: ...
6
votes
1answer
1k views

Using /proc/stat to calculate CPU usage

Inspired by this question: To calculate the total CPU usage as a percentage I wrote the following bash script (as an answer) to calculate the CPU usage for a (configurable) period over all CPU cores ...
12
votes
2answers
862 views

To calculate the total CPU usage as a percentage

I have been developing the below method to calculate the CPU usage of a Linux system at a point in time, as a percentage of the total number of cores available in the system. ...
4
votes
1answer
37 views

Script to fix audio level

I need to fix and maintain the master volume in PulseAudio (so that I don't blow up my speakers). E.g. call gfaaudio -v 25 to fix volume at 25%. Is there a cleaner ...
4
votes
2answers
63 views

A better way of always dumping Gedit out of Terminal?

I use terminal alot, so it was frustrating to me to deal with gedit's inconsistent behavior between having a window open and when one was not. I ended up searching around, and finding a way of getting ...