Tagged Questions

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
1answer
16 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
14 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
32 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 ...
0
votes
0answers
11 views

Watchfolder with inotifywait only adds the first new item [on hold]

This script file should add everything I put into the watchfolder to transmission, if I put one folder in the watchfolder it's works fine but if I add more then one folder at once it only adds the ...
2
votes
1answer
30 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
45 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
41 views

An atexit for Bash

I wrote the following atexit implementation for Bash ...
3
votes
1answer
37 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
112 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
115 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
297 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
30 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
68 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 ...
5
votes
4answers
223 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, ...
6
votes
1answer
117 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 ...
11
votes
2answers
418 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
33 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
46 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 ...
3
votes
1answer
76 views

Bash functions to run/manage MySQL, Redis, Sidekiq, Rails server

I'm working with a Rails app that requires a few layers of infrastructure to run: MySQL, Redis, Sidekiq, and (of course) the Rails server. I wrote some functions to help me manage the various servers ...
7
votes
3answers
439 views

Extracting data from text file in bash using awk, grep, head and tail

I've been writing bash script on and off, with pretty good results in terms of getting the job done. However, I'm worried that my script might be very ugly, as I am a beginner. I'm looking for advice ...
5
votes
2answers
62 views

Function autoloading in bash

I'm wondering if anyone can code review my code below. That's the core code of my little framework for bash in GitHub. ...
5
votes
2answers
82 views

File handling script

This is my first bash script so I ask to you to say what you think. The script must check every directory and if it finds a pdf file in this directory: move all the pdf files to parent directory, ...
6
votes
1answer
169 views

Git commit-msg URL shortener

I have just written my first git hook script. It is very simple that simply finds any URLs in the commit message and uses the Google URL shortener to rewrite the URL nicely. it is located here. I ...
-2
votes
1answer
34 views
4
votes
1answer
31 views

Generic Makefile

I decided to setup a generic makefile to compile SFML programs, as I'm going to be making a bunch of small apps over the next few weeks playing around with it. I'm still new to writing makefiles ...
2
votes
1answer
37 views

Cheat Code Scraper

During breaks, I find myself playing Emerald version a lot and was tired of having to use the school's slow wifi to access the internet. I wrote a scraper to obtain cheat codes and send them to my psp ...
4
votes
3answers
114 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. ...
5
votes
2answers
44 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. ...
5
votes
2answers
483 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
59 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 ...
7
votes
2answers
45 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
27 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
2answers
16 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
103 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
37 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 ...
2
votes
2answers
80 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 ...
4
votes
1answer
140 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 ...
9
votes
1answer
206 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
75 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 ...
5
votes
1answer
100 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 ...
4
votes
1answer
152 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 ...
8
votes
1answer
230 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
63 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 ...
7
votes
3answers
74 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 ...
3
votes
1answer
114 views
0
votes
1answer
57 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. ...
10
votes
2answers
106 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
100 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
46 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.) ...