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
6
votes
1answer
226 views

Statistical simulation

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 ...
4
votes
1answer
2k views
8
votes
1answer
247 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 ...
11
votes
2answers
128 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
360 views

Push backup script

I just wrote a little bash script for rsync push backups of my laptop to my Synology-Diskstation at home. Since I am a bash beginner and don't have any experience with ...
2
votes
2answers
64 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.) ...
1
vote
1answer
193 views

Parsing of a file using sed

I have a file containing lines having this structure : ...
2
votes
1answer
1k views

Bash pass multiple commands to SSH and make readable

I have a script that sends multiple commands after logging in a remote machine via SSH. Problem is, it's barely readable. I've tried quoting everything with "", but it's terrible (everything appears ...
8
votes
1answer
740 views

Bash script - automate an upload image + description process on a server

I was tasked at work to improve a system where through a web interface a client, which eventually became us, uploads a bunch of images with descriptions (latter coming from csv files), the images are ...
7
votes
2answers
23k views

Running a shell command and getting output

This is the code I'm currently using to run a shell command on the current machine, intended for use only with GNU/Linux at the moment: ...
6
votes
2answers
828 views

Text snippet creator/manager in Bash

Below is a script to create and manage text snippets. It is also posted on GitHub. Most of the code is error checking and displaying help because I wanted to make a solid command line interface. The <...
4
votes
2answers
248 views

Mixing function parameters, commands and command arguments in Bash functions

I'm trying to write a bash function that will take a command such as xcode-select -v or brew -v that outputs a lot of extra text,...
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
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 ...
2
votes
1answer
359 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 ...
1
vote
1answer
352 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 ...
2
votes
1answer
875 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
1k 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. ...
1
vote
2answers
139 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 ...
2
votes
1answer
690 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 ...
4
votes
1answer
2k 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 shell ...
4
votes
1answer
768 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. ...
2
votes
1answer
1k 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 ...
3
votes
2answers
1k 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 ...
1
vote
1answer
1k 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 ...
3
votes
1answer
766 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 ...
2
votes
1answer
152 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 ...
4
votes
1answer
329 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 ...
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. ...
5
votes
2answers
120 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 ...
3
votes
1answer
859 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 ...
2
votes
1answer
296 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 ...
2
votes
1answer
258 views

Concept for PHP Controlled, Privileged Execution (for a cPanel knockoff on Ubuntu Server)

I was thinking of building a F/OSS project as a cPanel for Ubuntu Server, since Ubuntu doesn't have this, and yet making it easy for a hosting company to use this, where users will find it just as ...
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 ...
1
vote
2answers
547 views

optimizing a bash script chain - speed suggestions?

i am testing an application that i wrote and want to test the solution my algorithm produces to a Monte carlo solution. I use the harddisk a lot and i was wondering if there was a solution that uses ...
6
votes
1answer
278 views

How to improve my auto-reconnection Python script

I need some feedback here. Due to a weird issue on my server system, the network card disconnects from the network regularly. I'll fix this at a later date. But I wanted to know if the below script ...
5
votes
1answer
134 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 ...
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. <...
8
votes
3answers
469 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 ...
2
votes
1answer
438 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 ...
5
votes
1answer
7k 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! ...
3
votes
1answer
4k views
3
votes
2answers
220 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
1answer
180 views

CommonJS modules/require at build-time with bash and M4

I've implemented CommonJS Modules 1.1.1 as a simple bash script with a bit of help from M4. I'm interested in comments on the shell scripting and the javascript output. Some specific questions on ...
3
votes
2answers
91 views

How to improve the way I handle greping in this script

What my script does is: Append data to a file on a continuous basis. If an error pattern is observed, then do something. I need feedback on the way I am grepping for patterns in the continuously ...
6
votes
3answers
1k views

Script to monitor a folder and compress the content

We have a Debian Squeeze server where we upload files through SFTP, and I wrote this script to automatically compress uploaded files. The script is scheduled through a cron job in an unprivileged ...
3
votes
1answer
7k views

Shell script that creates and deletes symbolic links

Right now I am working on an install and uninstall script for my vim configuration files. The install script links files and directories and the uninstall script deletes those links. I just want to ...
4
votes
2answers
981 views

Script to group files by extension and unzip archives

I am writing a shell script to sort my files by extension and unzip archives. It works in simple cases, but I haven't tested it extensively. How can I make it more robust against the set of file names ...
1
vote
3answers
95 views

Counting last reported version in shell

Struggling to write a simple tool to quickly sum up the last reported versions in a bunch of files. I'm using a named pipe to get the count out the loop for the final value, but the $version isn't ...
2
votes
2answers
95 views

Shell script: is it doing what I think it's doing

I've not written many shell scripts and cobbled this together from examples. The 'if' condition should check if this is already running and quite if so. The 'wget' call should trigger the php page and ...