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

4
votes
2answers
50 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 find . -type f -name "<search_pattern>" > foundlist.lst I would now like to use this list to find copies ...
1
vote
1answer
26 views

Bash script to monitor Webserver php script

Below is a script I wrote today to use CURL to monitor the length of various HTTP server outputs and output a response if this is different than 103 characters. This is my first bash script, so I had ...
0
votes
1answer
64 views

Spell check interview problem in Bash

Thanks for taking the time to read this. I submitted a code screening for a company I really wanted to work for and spent a decent amount of time on their programming assignment. Pretty bummed when ...
3
votes
4answers
32 views

apt alternative for proxy environment with bash shell

As I am new to bash scripting, and want to use apt-get in my university. I know that many people have issues when trying to do so. My focus is simplicity and ease of use, but still need to be ...
2
votes
1answer
39 views

Bash to find all placeholder variables in a file and replace will real variables

I am looking to make a generic config file using variables such as: $PLACEHOLDER_USER Then after moving the file into the correct position I want to replace every instance of *$PLACEHOLDER_VARIABLE* ...
1
vote
1answer
128 views

Send email if URL is down for 2 times only - bash shell script

we want to check if URL is down or not. But sometimes, environment is down for maintenance for 3-4 hours and we dont want to keep sending emails during that time. I have written a shell script for ...
1
vote
2answers
87 views

Floating-Point data input in Bash and C

I wrote a function that dynamically stores statistical data. I tried to clone the functionality of how I had originally written my solution in Bash. Is there perhaps something I could improve, or do ...
0
votes
0answers
70 views

Project Bashory - Bash History - Any suggestions on improvement?

In effort to be more effective and productive with terminals I have started building a bash script. It is for handling the bash history of concurrently running terminals, archiving old commands, and ...
1
vote
1answer
58 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 supports all the subcommands of ...
1
vote
1answer
68 views

Bash script to set up an ad hoc wireless network

This script creates an adhoc network using hostapd. I have tested it and seems to work reliably. I am new to linux networking and not sure if this is a recommended way to create an adhoc network this ...
3
votes
1answer
65 views

New svn repository script

This is my very first Bash script that does something real. I'm here to learn, so please tell me if and how this can be done better. #!/bin/sh # Daniele Brugnara # October - 2013 if [ -k $1 ]; then ...
2
votes
0answers
60 views

OSX: AppleScript to close running processes

I've been trying to emulate MS Windows behavior on my OS X and close processes that do not have a window. What I'd really like to do is "quit" the process on clicking the red "x" button. Instead, i ...
2
votes
2answers
72 views

Automating easy-rsa cert creation with Bash script

In order to make cert creation with easy-rsa as practical for others, this script was created and it works so far. The questions are: where can it be improved? are there flaws that are not obvious ...
0
votes
1answer
35 views

Automating the install of postgresql from Shell

When my debian server deploys it can run a shell script so I wanted to make one to install postgreSQL, create a role, create two databases and then import a schema into one. Can anyone please look ...
0
votes
1answer
41 views

Trying to remove dashes from files [closed]

Here is what I have. It runs OK unless there are no files with dashes, then I get: mv target filenameblah is not a directory. What am I missing? for i in *-* do mv $i `echo $i |tr -d -` ...
1
vote
1answer
152 views

script- loop through files and directories

I have written the script, which unzips a zip file (passed as argument to the bash), loops through directory and files, then perform different actions based on directory or file. It is working fine. ...
0
votes
0answers
84 views

Push backup script

I just wrote a little bash script for rsync push backups of my laptop to my Synology-Diskstation at home. See the code below. Since I am a bash beginner and don't have any experience with ssh, rsync ...
1
vote
1answer
35 views

Input Columns with Awk

I wrote a small script to manipulate fields of a file based on the input of a user. Is there something I could've done better, or perhaps a better refactor? I do know however that I need a way to ...
1
vote
2answers
68 views

Bash log monitoring optimization

I've made a Bash script to monitor some server log files for certain data and my method probably isn't the most efficient. One section specifically bugs me is that I have to write a newline to the ...
1
vote
1answer
154 views

bash script to organize files and cleanup files

I have been working on a bash script for a while now to organize my movie files. I can do it by hand, but at the time I was taking a bash scripting class and thought I would like to use it to create ...
0
votes
0answers
74 views

Directory's disk usage list

For my classes i had to finish this task. Problem 5.5 Directory's disk usage list For indicated directory print a list of files and subdirectories in descending order according to their total disk ...
2
votes
1answer
364 views

SpamAssassin spam analyzer script in PHP based on sa-learn command

I wrote a small script to analyse spam messages that are spam false negative; meaning that they are spam messages in nature but that happened to be in your INBOX folder because your spam filter failed ...
2
votes
1answer
183 views

Simple IPSec/tunnel setup script

I've developed a script to set up an encrypted tunnel between two Linux hosts, using iproute2, ssh and setkey. The goal is to allow setting up ad-hoc secure tunnels with minimum of setup and ...
2
votes
1answer
95 views

Simple bash script for opening a repository in the browser from the command line

I'm relatively new to bash scripting, and I'm wondering how I've done on this. Basically it's a script where if I'm in a github or bitbucket repository in my terminal, I can type browse-repository to ...
1
vote
1answer
60 views

Bash script to manage multiple Java Development Kits installations

I'm writing a bash script to manage multiple JDKs, the script is very simple, you have to choose a directory when you store all the jdk's, and the script maintain a symlink to the current jdk'. ...
1
vote
2answers
290 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. #!/bin/bash usage() { echo "Program for ...
2
votes
1answer
387 views

Bash Shell Script uses Sed to create and insert multiple lines after a particular line in an existing file

This code seems to work, but I'd like someone with shell-fu to review it. Is the temp file a good idea? How would I do without? Is sed the right tool? Any other general advice for improving my ...
-1
votes
1answer
39 views

bash file manipulation [closed]

I have files in a directory named so: 1welcome.avi 2introdution.avi I have a rhcsa.txt file that has what these files should be named as: rhcsa_1_welcome.avi rhcsa_2_introduction.avi both the ...
1
vote
1answer
278 views

run external command from python

I have to run an external program from python. External program makes many temporary files (which conflict with other instance of same program). My strategy is Get current directory (native) path, ...
1
vote
2answers
211 views

Shell script to copy video files to another folder

I recently started running but hate running both in the quiet and with music, so i've been listening to podcasts. Unfortunately, I've caught up with all my favorites and so I've started listening to ...
2
votes
1answer
129 views

Improve a script to generally check status of several git repos

I've tried to write a bash script that gives me a general overview of the status of git repos I have cloned/created. It's not meant to replace git status by any means, but give an overview of several ...
2
votes
2answers
141 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 to use one common library for ...
4
votes
2answers
51 views

Make a directory and change to it

A basic shell function to create a directory and change to it goes like this: mkcd () { mkdir "$1" && cd "$1"; } This works well in many cases but breaks in unusual cases (e.g. if the ...
5
votes
2answers
85 views

bash: Can anyone think of how to make this nicer/prettier/more readable?

my first post. Just created a teeny little script to count the seconds until I get auto-logged off. I already solved my issue with my ssh client settings, but I'd still like any help making the bash ...
0
votes
1answer
98 views

Parsing of a file using sed

I have a file containing lines having this structure : var marker25 = createMarker(point, '<div id="infowindow" style="white-space: nowrap;"><h3>Katz\'s Deli</h3>205 E. Houston ...
4
votes
1answer
118 views

Please review my statistical simulation to help me improve my C

I've written the following program as a submission to the German Federal Computer Science Competition for highschool students. The program makes the following simulation with a given number of days ...
1
vote
2answers
159 views

Bash Backup Script

The following script closes a virtual machine (which is run in a screen session), waits for the session to close, creates a backup of the VM, and restarts the VM. The shutdown and bootup scripts speak ...
3
votes
2answers
133 views

Bash Script(beginner) - Code Improvement Suggestions

I am writing a simple script to automate my regression testing. I am new to bash scripting and my goal is achieve the most efficient and clean code. I have written a simple function to allow me to ...
3
votes
2answers
76 views

A little bash function, assigning attributes

This function checks if an attribute has been passed and if not, asks user for input. I'm new in bash scripting and would like to get some feedback. Is it okay or should I refactor this code somehow ...
5
votes
3answers
118 views

Can I speed up this simple versioning/backup script?

I'm writing a simple automatic backup/versioning bash script. It should basically mirror a directory structure somewhere, and then copy files over there when they've been altered. The ghost files ...
3
votes
1answer
109 views

An attempt at making a neat ls

This is a simple script to make ls output first folders, then files, then other stuff (symlink). I think this is really neat and would like to share the script in exchange for comments. It should be ...
3
votes
1answer
203 views

Am I making any beginner errors in the bash script for adding trusted timestamps to Git commits?

I don't write too many bash scripts and I can usually struggle my way through getting the odd thing I need working, but my scripts always seem to feel a bit brittle. Below is a script I wrote for ...
2
votes
1answer
167 views

Run all scripts in a sub-directory

When git runs my post-receive hook, I'd like it to run all the scripts in the subdirectory post-receive.d. My script is as follows #!/bin/bash SOURCE="${BASH_SOURCE[0]}" DIR="$( dirname "$SOURCE" )" ...
3
votes
1answer
179 views

Bash function to create the next SVN release tag

I've created the below script and would appreciate any feedback. # svn directory ^/tags/release/ # 1/ # 2/ # 3/ # 4/ # usage: svnnextrelease fixes email formatting # generated line: svn cp ^/trunk ...
1
vote
1answer
383 views

Bash script for reverse engineering Android applications

I'm new to bash scripting and need some help improve a script I made for working with reverse engineering Android applications. I wrote comments in the script itself to explain what I want to do. ...
2
votes
1answer
227 views

Tips on good practice in my bash script that logs in to a website, downloads a PDF, adds it to iBooks and uploads it to dropbox

I am running a scheduled script on my iPhone that logs in to a website, downloads a PDF, adds it to iBooks and uploads it to dropbox. All of this happens only when it has WiFi access. I want to make ...
3
votes
1answer
1k views

Shell script that verifies checksums when moving between filesystems

I coded this because it seemed like a fun project, would be awesome if someone reviewed this. Thanks! #! /bin/sh #function that checks if dependencies are installed check_software() { #check ...
3
votes
1answer
409 views

Bash arrays and case statements - review my script

#!/bin/bash # Change the environment in which you are currently working. # Actually, it calls the relevant 'lettus.sh' script if [ "${BASH_SOURCE[0]}" == "$0" ]; then echo "Try running this as ...
2
votes
2answers
161 views

Bash script to share snippets of code using rsync

I just got through writing a bash script so my friend and I can share snippets of code to a central file via rsync and ssh. What it does is this; Sets up ssh public key auth if not already working. ...
1
vote
3answers
1k views

Bash script to swap out, edit host files

So this is my first useful bash script. It's meant to make it easy to switch between a "work" hosts file (that blocks sites like reddit.com, youtube.com, etc.) and my normal hosts file, and also to ...