The term 'shell' refers to a general class of text-based command interpreters most often associated with the Unix & Linux operating systems.
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 ...
7
votes
3answers
115 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:
i=/sbin/iptables
# Flush all rules
$i -F
$i -X
# Setup default ...
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 ...
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)
{
...
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 ...
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
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 ...
1
vote
2answers
49 views
Remove NULL / empty fields using awk
just wanted to check with you could this be done better:
awk -F"\t" '{
for (i = 1; i <= NF; i++) {
if ($i != "NULL") {
printf("%s%s", $i, FS);
}
}
...
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* ...
3
votes
1answer
141 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:
if echo "$2" | ...
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 ...
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 ...
1
vote
0answers
35 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
58 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.
""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the ...
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 ...
3
votes
0answers
42 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 ...
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 ...
1
vote
3answers
78 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
132 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:
for file in *
do
if [ -f "$file" ]; then
...
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'. ...
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 ...
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 ...
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 ...
7
votes
3answers
137 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
458 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
194 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
155 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 ...
3
votes
1answer
2k 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 ...
1
vote
1answer
168 views
Converting Bash commands into Windows cmd commands
I have the following code that converts a couple of bash commands into Windows cmd commands, as well as adding some commands. This is only my second day programming in C++, so any and all suggestions ...
1
vote
0answers
159 views
Plan9 rio script to tile windows. How can I improve this (rc-shell)
Here is my window tiling script for rio window manager in plan9. It fetches the current screen size, and calculates the locations based on the layout given. How can I improve this program? am I ...
3
votes
3answers
252 views
Shell script to sync dotfiles repository
I'm doing the git dot files thing and created a script -- my first Unix shell script -- to synchronise the repo dot files with those in the user's home. It checks which dot files exist in the repo ...
1
vote
0answers
79 views
Criticize my first awk program
Consider the following CSV file:
A; B; ;
B; ; A;
C; ; E F;
D; ; E;
E; C; ;
The fields:
$1: the jname. A unique id of the entry.
$2: a " "(space)-separated list of incond.
$3: a " ...
3
votes
2answers
517 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
1answer
157 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 ...
2
votes
2answers
82 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 ...
4
votes
1answer
327 views
Transpose a matrix using sed
Transpose the following data from:
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 ...
1
vote
1answer
186 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 ...
2
votes
1answer
219 views
Collapsing Folder Trees with Ruby
This is a quick script I whipped up to collapse some folder trees down to individual folders. The specific situation that arose was my formerly-itunes collection (it's currently organized ...
3
votes
0answers
467 views
PowerShell Module for formatting objects using Razor
A few days ago I started playing around with PowerShell. I thought a good way to learn would be to try and write a module that allowed formatting objects using the Razor Engine created for ASP.NET.
I ...
4
votes
3answers
833 views
Does this shell script look ok?
I don't want anything to execute if any preceding step fails:
#!/bin/sh
file="v0.9"
renamed=$file".tar.gz"
dir="utils/external/firepython/"
...
11
votes
3answers
818 views
Was this shell script ready for open-source? (Random XKCD wallpaper)
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 open-sourced/published ...