BASH is the Bourne Again SHell, the successor to the classic Unix sh (shell). It's the official shell of GNU.
1
vote
1answer
22 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
1answer
42 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
59 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
13 views
crontab+script does not exit at end of process
I've create the backup script below, and added it to crontab using the latest webmin.
Problem: The script doesn't exit, which results in several rsync threads being visible in top after a few days. ...
0
votes
0answers
43 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
254 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
77 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
47 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
39 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
94 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 ...
1
vote
1answer
302 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
27 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
98 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
130 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
79 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
99 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
33 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
79 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
69 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 ...
2
votes
1answer
88 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
133 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
112 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
66 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
89 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
104 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 ...
2
votes
1answer
143 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
121 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
111 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
294 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
185 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
829 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
295 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
151 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
964 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 ...
4
votes
2answers
789 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.
#! ...
2
votes
1answer
1k 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 ...
2
votes
2answers
341 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 ...
0
votes
1answer
100 views
Problem with writing “Bash Script” [closed]
Please help me. I have a problem with writing "Bash Script". I just began to study "bash scripts", so I need help. Could someone write to me some "bash scripts"? I'll be very grateful.
2
votes
2answers
367 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 ...
5
votes
3answers
358 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 ...
2
votes
2answers
83 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 ...
4
votes
2answers
212 views
Suggestions needed to improve my code ( bash script)
I wrote a bash script to print contents of files in a given directory in a loop. I kindly need suggestions mainly on the following aspect:
How can I improve command line parameters handling to the ...
5
votes
4answers
212 views
How can I simplify these bash if statements before it gets out of hand?
We have a setup script for setting up a development environment, and setting up the image libraries is getting a bit messy:
# this is to get PNG and JPEG support working in PIL on Ubuntu
if [ -d ...
1
vote
1answer
137 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 ...
1
vote
3answers
81 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
81 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 ...
2
votes
2answers
393 views
Tiny bash script: Is sed necessary here?
I've recently discovered the power of sed; regular expressions seem like they'll take a lifetime to master. This tiny script uses both to add zero before the single digit in file names.
Can this be ...
5
votes
1answer
199 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 ...
2
votes
2answers
320 views
bash script for printer administration
#!/bin/bash
# Used to add/remove printers from system (lp)
# Copyright Fresh Computer Systems Pty Ltd.
GREP_OPTIONS='--color=tty'
export GREP_OPTIONS
sanity() {
# Are we root?
if [ $EUID ...
6
votes
4answers
220 views
How can I make this password search more inteligent?
In a homework, there is exercice when I have a script that is used to search a password.
One of the questions is if is possible to make it "more inteligent", and I'm stuck on it.
The script:
...