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

10
votes
2answers
1k views

Can you break this code?

After growing tired of all the ways in which a file loop can be broken (find -print | while read) or unreadable (find -exec with complex commands), I think I've managed to build a find template which ...
7
votes
3answers
671 views

Was this shell script ready for open-source?

I wrote the following little shell script. I published it on github. In the repo there's also a README file, that explains how to use it in more detail. This is the first time I ...
6
votes
4answers
217 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: ...
5
votes
4answers
200 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 ...
5
votes
3answers
73 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 ...
5
votes
1answer
193 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
3answers
302 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 ...
5
votes
2answers
74 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 ...
4
votes
2answers
204 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 ...
4
votes
2answers
711 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. #! ...
4
votes
2answers
29 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 ...
3
votes
2answers
63 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
238 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 ...
3
votes
3answers
390 views

Need help improving a small C program

I wanted to launch a bash script (read: bash not sh script) as a root not as the user calling it, however bash ignore setuid on scripts, so I chose to write a very small script that takes a ...
3
votes
2answers
96 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 ...

1 2 3 4
15 30 50 per page