BASH is the Bourne Again SHell, the successor to the classic Unix sh (shell). It's the official shell of GNU.
7
votes
2answers
72 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 document. I usually manually execute this in the terminal as
$ ls foo*
foo.tex
...
6
votes
1answer
47 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
32 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.)
do_something ...
2
votes
1answer
58 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 ...
6
votes
2answers
85 views
Bash script that updates Intel e1000e driver
I am now writing a small bash script that updates an Intel NIC driver to the latest version from the official website. Is there any way to improve\simplify the script? I want to avoid a lot of ...
6
votes
1answer
56 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 ...
5
votes
2answers
132 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 ...
5
votes
2answers
156 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:
std::string getCmdOutput(const std::string& mStr)
{
...
5
votes
0answers
55 views
Connecting to EC2 instances using the instance name instead of IP
I'm an intensive user of AWS EC2 instances, many instances are launched, stopped, repurposed, etc.
To connect to any instance using SSH I must keep track of their IPs.
The bash script I wrote ...
2
votes
1answer
72 views
Ruby install script; packages+installs as a .deb or .rpm from source?
I have a variety of scripts of this form:
#!/usr/bin/env bash
RUBY_VERSION=2.1.0
printf "Installing Ruby $RUBY_VERSION\\n"
if [ -d ruby_build ]; then
rm -Rf ruby_build
fi
if [[ `command -v ...
9
votes
1answer
68 views
Help speeding up my first Bash script
This is my first more-than-1-line script. It takes an inputfolder and a file prefix and get all the files matching. For the first of the files, the script grabs the first line and appends an extra ...
1
vote
1answer
53 views
Interactive menu system in Bash [closed]
This is a simple loop menu script that I have for class. The goal was to make a menu with applicable commands.
Menu:
A. Greet me. (Greet the user by their username (using the whoami ...
3
votes
2answers
61 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, and format it to my liking. Just to further the example, say I run ...
1
vote
2answers
46 views
Managing while loop in bash
Two difference scenario in bash program,
First
Here i am breaking loop in function testFunc.
#!/bin/bash
function testFunc {
if [ some condition ] ; then
break
fi
}
while [ 1 ]
do
...
3
votes
2answers
59 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
67 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 ...
2
votes
1answer
71 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
103 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 ...
4
votes
4answers
50 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
113 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* ...
2
votes
1answer
455 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
104 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
0answers
97 views
Project Bashory - Bash History
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 ...
2
votes
1answer
66 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 ...
2
votes
1answer
130 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
103 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
...
3
votes
2answers
141 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
50 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
44 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
413 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.
...
6
votes
1answer
128 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 ssh, rsync and backups I am ...
2
votes
1answer
44 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 ...
2
votes
2answers
72 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 ...
2
votes
1answer
178 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 ...
1
vote
0answers
94 views
Directory's disk usage list
For my classes, I had to finish this task:
Directory's disk usage list
For indicated directory print a list of files and subdirectories in
descending order according to their total disk ...
1
vote
1answer
404 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
224 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 ...
3
votes
1answer
126 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 ...
2
votes
1answer
69 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'. ...
2
votes
2answers
365 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 ...
3
votes
1answer
481 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
43 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 ...
2
votes
1answer
449 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, ...
2
votes
2answers
221 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 ...
3
votes
1answer
175 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 ...
3
votes
2answers
163 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 ...
5
votes
2answers
61 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 ...
6
votes
2answers
87 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 ...
1
vote
1answer
112 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 ...
5
votes
1answer
129 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 ...