The term 'shell' refers to a general class of text-based command interpreters most often associated with the Unix & Linux operating systems.
2
votes
1answer
11 views
Optimize bash script that concatenates output
I am trying to optimize my script that loops through a folder and extracts only the part of a file name before a date and the header of the file and outputs it into a different file using a delimiter. ...
3
votes
2answers
29 views
Reading options from .cfg file
I have a bash script that reads a config file with key/value pairs and uses these values to modify the functioning of other scripts correspondingly.
Example .cfg file:
...
6
votes
1answer
41 views
Monitor Downloads folder and sort files as they are downloaded
I have written my first shell script that uses inotify-tools to monitor my Downloads directory. What I intend to do with the script is that, as soon as a file is ...
4
votes
2answers
45 views
Team git commit cleaner
I cleaned a big repository for my team with this Python code. My goal was for every developer in my team to check if some bad email are in the commit, and replace the information by the good one. I ...
2
votes
0answers
25 views
Replace while loop with sed
I have a script for school that mimics the cp command. Part of the assignment is to modify the script so that the while loop (that assigns stdin to the variable filelist) is instead done with sed.
...
0
votes
1answer
46 views
Is this iptables firewall bash script good? [closed]
I'm learning to use iptables to implement it in my company software. The goal is either to prevent the major attacks and to have good speed transferring files (ssh and ftp). Can you help me to improve ...
1
vote
1answer
64 views
Simple Bash backup script - follow-up
As a follow up to a previous question, linked here, I have revised the code and developed what I believe to be a better solution.
In summary, the script should backup all files in a particular ...
3
votes
1answer
123 views
Simple Bash log backup script
I have developed the following script to zip and then remove all files with "*.log" extension in the file name that were modified yesterday. It's definitely not 100% at the moment. For example, it ...
1
vote
0answers
20 views
Basic Unix shell that displays prompt and has two simple commands [closed]
I'm writing a really basic shell for Unix in C. It displays a prompt, [almond], and it has two commands: Set Prompt and exit. I'm reading user input and passing it to a char array, then parsing it ...
3
votes
1answer
37 views
Can this bash shell script that checks for rvm ruby versions be improved?
As it is going to be used as part of some automation and not just at the command line I was wondering if it could be improved at all.
Improve would mean any of:
handle sad cases better
handle ...
8
votes
1answer
403 views
Securely delete a file
I am trying to write a script to securely delete a file. What I am intending to do is to pad the file with /dev/zero once, and then with /dev/urandom three times and then delete the file.
For now the ...
3
votes
1answer
51 views
Bash archiving script
I inherited a script at work the other day. I know very little about the command line in general but I'm not entirely new to programming. I am using this as an opportunity to learn... Very little ...
7
votes
3answers
272 views
Simple shell in C [closed]
I am just getting started with C and made this simple shell to test my understanding of some basic principles. The shell reads commands from standard input, forks itself and executes the command. How ...
3
votes
2answers
116 views
Group and send all files to filetype folder
I have around ~2M of files in one folder, which I need to manage. So, I want to separate them in groups by their filetypes.
Example:
filenames
...
5
votes
2answers
71 views
Function autoloading in bash
I'm wondering if anyone can code review my code below. That's the core code of my little framework for bash in GitHub.
...
4
votes
1answer
118 views
Shell script for creating CR questions
Inspired by Tool for creating Code Review questions.
This script generates a markdown document suitable for a CR question from a list of files. For each file it finds, it sends the following to ...
2
votes
2answers
82 views
Comparing if-else and case condition
I have a script used for installing few rpms depending on operating system type. Here in this example, the script will install packages on two system "centos" and "suse". The system names are listed ...
10
votes
1answer
230 views
Bash Music Player 2
This post is a follow-up to this.
I wanted further reviews since the code I provided became too old when I got replies, which is why I'm providing it again here.
I'm hoping I could get reviews for ...
6
votes
1answer
51 views
Directory of Snapshots
I have snapshots (photos) that I load off my camera's memory card, and store in a folder. Sometimes I have videos, and occasionally plain audio too (the camera can record just sound).
Additionally, ...
4
votes
1answer
177 views
Bash Music Player
I have finally finished creating my first real project. It's just a simple music player that can provides the user with the latest music from any site (as long as it contains MP3 files) he provides ...
7
votes
1answer
111 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 ...
8
votes
3answers
211 views
Iptables Lockdown
I have nginx serving files with uwsgi and I wanted to lock my server down just to allow SSH and Nginx to run. This is what I have:
...
9
votes
3answers
536 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 ...
5
votes
2answers
331 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
3k 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:
...
1
vote
1answer
328 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
109 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 ...
3
votes
2answers
116 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
4answers
91 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 ...
1
vote
2answers
106 views
2
votes
1answer
378 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* ...
3
votes
1answer
431 views
Make a git repository read-only over ssh depending on the key used
I want a git repository, accessible over ssh, to be read-only when used with certain keys. With other keys access to the full system is okay.
Here is my solution.
git-readonlyshell:
...
3
votes
1answer
1k views
Send an email if a URL is down twice only
We want to check if a URL is down or not. But sometimes, the environment is down for maintenance for 3-4 hours and we don't want to keep sending emails during that time.
I have written a shell script ...
5
votes
1answer
137 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 ...
1
vote
0answers
46 views
zsh system status script
The following script is being used to generate the status line in wmii. I'm curious if there are faster/more efficient ways to find the various info I'm grabbing. I'm also a relative newbie when it ...
1
vote
1answer
66 views
Checking if a git repository needs to be updated
I made a small Vim distribution that uses vundle. I decided to make a small function that checks if the repository must be updated.
...
1
vote
1answer
130 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 ...
3
votes
0answers
47 views
A z-shell function to quickly cd into projects
I think we all now that problem. We work with multiple projects: private projects, company projects, probably even projects for multiple companies.
From day-one, I've always searched for better ways ...
3
votes
1answer
53 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
3answers
83 views
How to improve the computation speed of my shell script/program?
I have written a shell script to process my huge data files (each one having around 7,000,000 lines ~ a weeks data in a single file). Below is the sample of my data file (i.e., input file) structure:
...
2
votes
1answer
265 views
List contents of a folder using a shell script and mail the folder
I want to list the contents of a folder and mail the list using a shell script. I Came up with the following script, please let me know if it is okay:
...
2
votes
1answer
103 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
1k 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 ...
3
votes
1answer
375 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 ...
5
votes
2answers
84 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 ...
7
votes
3answers
188 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 ...
6
votes
2answers
1k views
Shell script to help with branch management for tasks in git
I found nvie's git branching model simple enough to grasp and suitable for my projects - but the frontend supplied at GitHub was far too complex for me to understand. Hence, I wrote this script to ...
2
votes
1answer
253 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 ...
4
votes
1answer
200 views
Review logic in shell script
I have a shell script to mount different remote systems. While it does work, the area I struggle with (not being a programmer) is the logic of the script: it feels quite stilted and there seems to be ...
4
votes
1answer
3k 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!
...