Questions tagged [shell]

The term 'shell' refers to a general class of text-based command interpreters most often associated with the Unix & Linux operating systems.

Filter by
Sorted by
Tagged with
19
votes
2answers
1k views

Yet another shell in C

I wrote this shell in C about a semester ago for a university assignment on operating systems. Even though I got a score of 10/10 in this assignment, I doubt it deserved it - The pipeline ...
17
votes
0answers
1k views

PowerShell module for formatting objects using Razor

I managed to get something up and running, but I've no idea whether there are better ways to do this. I've spent all morning trying to figure out the best way to use parameters (allowing objects from ...
14
votes
3answers
265 views

Mission impossible: beat everyone else to the queue

Your mission, should you chose to accept it, is to beat everyone else to the review tab so you get a chance to help out. This is a problem I've been running into lately. I go over to review tab, find ...
14
votes
1answer
10k views

Clone GitHub repository using Python

I want to backup my GitHub repositories since there is news about blocking GitHub in India. I wrote Python code to automate this and would like for it to be reviewed. ...
13
votes
5answers
3k views

Git delete all merged in local branches

I have written a shell script utility for deleting all merged local branches. ...
13
votes
3answers
1k views

Was this shell script ready for open-source? (Random XKCD wallpaper)

I wrote the following little shell script and 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/...
12
votes
3answers
2k views

PyDOS shell simulation

I have a big project called 'PyDOS', written in Python 3.4, and it's going very well. Post your answers of anything that could make it look cleaner. ...
12
votes
3answers
2k 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 "if......
11
votes
2answers
2k views

Memoizing or caching Bash function results

Update: I've implemented several of the features suggested below and packaged the improved code into a dedicated project: bash-cache. I display a number of expensive operations in my Bash prompt (e.g....
11
votes
1answer
884 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 ...
11
votes
2answers
730 views

Editing Javascript and rendering HTML in one window v2

I wanted to revisit this site to post some recent work I put into this small project. I was able to add a console as suggested; but I thought I would ask here how my coding stying is before I work on ...
11
votes
3answers
235 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 ...
10
votes
3answers
850 views

Shell Script (Bash) to sum multiples of different arguments below a number

I'm interested in learning how to create shell scripts with bash so here's one of my first exercises, taken from here. It is an extension of the problems Elementary - 4 and 5. The goal of the program ...
10
votes
1answer
365 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 ...
10
votes
2answers
290 views

mini-(Docker)-shell

I was given an assignment to write a mini-shell: To write your own shell, you will need to start with a C program that will prompt the user for input and accept in a number of arguments from a ...
10
votes
1answer
131 views

POSIX shell compatible and POSIX conforming dirname implementation

The discussion in the comments of this answer made me wonder how hard it would be to write a built-in only version of dirname. This is what I ended up with but I'm ...
9
votes
2answers
1k views

Count line of code for a JavaScript project

Here is my bash script that I just wrote to count line of code for JavaScript project. It will list number of: Comment lines Blank lines All lines Here is my script: ...
8
votes
3answers
28k 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 ...
8
votes
3answers
647 views

PS1 for Bash prompt showing last exit status, written mostly in Python

I had most of this functionality accomplished in BASH, but I was having trouble getting the last process's return value (even though I had a minimal working example). Plus, the escape codes made ...
8
votes
2answers
240 views

Recovery Shell (rsh)

I wrote a shell to test my understanding of processes etc. It is not supposed to comply with POSIX or anything, just to allow people to run simple commands with simple arguments. ...
8
votes
3answers
498 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 ...
8
votes
2answers
185 views

Copy files in parallel by reading what files to copy from few other files

I am working on a little complicated shell script for the first time and this is what it should do: During startup, it figures out what is my clientid by looking ...
8
votes
2answers
26k 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: ...
8
votes
1answer
257 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
1answer
646 views

My Pythonic take on Psexec

I've created a little program that basically does the same thing as psexec. It will connect to a host via computer name, or IP address, run the given command, and log the output into a file (little ...
8
votes
2answers
162 views

Backup Linux system to web

First I create a .tar of the root directory with all the file permissions saved and excluding all irrelevant directories (are these the right folders to be ...
8
votes
2answers
8k views

Shell script to assist 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 ...
8
votes
1answer
278 views

Extracting single files from a tarball (spreadsheets)

I've created a program that will pull spreadsheets out of a large tarball. First it specifies the file name through the "folio" number which is given as an argument when the program is called. From ...
7
votes
4answers
1k views

PyDOS: Version 2.0

This is a follow up question to PyDOS shell simulation. You might remember PyDOS from my other post. I have now updated it and it's better than ever! Post any ideas below that could make it better. <...
7
votes
5answers
992 views

Shell script to download and extract a tarball from GitHub

I don't want anything to execute if any preceding step fails: ...
7
votes
3answers
480 views

Inserting command output into multiline string

I'm writing a bash script to that picks up a user password from an environment variable, hashes this, and inserts the results into a postgres database. What I have works and looks fairly readable to ...
7
votes
3answers
262 views

NRPE script for monitoring load average

This script converts a server load value into percentage, compares it with non desired state ($warning and $critical) and returns all information in NRPE (Nagios Remote Plugin Executor) friendly ...
7
votes
1answer
613 views

Basic shell in C

I'm new to C and created this shell to test my knowledge. It takes input from stdin, checks whether the full path has been given, if not, appends input to /bin/ and then executes. How can I improve; ...
7
votes
1answer
1k views

Detecting keyboard input

I want to use JavaFX as a solution to Java's issues with buffered input making things like 'press any key to continue' not easy. I plan to use an event listener to detect keyboard input. But before I ...
7
votes
3answers
176 views

Shell Script Image Replication

I have a shell script which is being used on an embedded human machine interface (HMI). This script is used to copy a few files from a USB stick to a different place on the device, but with multiple ...
7
votes
1answer
132 views

Restrictive stupid shell

I'm attempting to create a replacement shell for /bin/bash, that only permits commands defined by a read only config file. These commands will be run by absolute paths, and take no arguments. I'm not ...
7
votes
2answers
133 views

Bash script to send notifications when low on ram

Backstory Recently, we've changed the PCs at my workplace to un Linux Mint. It works amazing, is blazing fast and the adjustment time was very short. However, I noticed my PC would freeze completely,...
7
votes
1answer
85 views

Squire for your recursive SSH adventures

One day I used to SSH to lots of machines to do some administrative tasks. I constantly used l to list directories just like I do on my own machines. Guess what, ...
6
votes
2answers
1k views

Test to see if installed and if not, install it

Okay all you Linux/shell folks out there. This is my first shell script (2nd if you count "Hello World") and would appreciate some feedback. Basically, I need to test whether ...
6
votes
2answers
837 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 <...
6
votes
3answers
2k views

Check disk space against a threshold

The below script is one I made to check the disk space on mounted partitions under Debian Wheezy. I tried adding a -d switch to force printing out the used data, ...
6
votes
2answers
143 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. ...
6
votes
2answers
1k views

Address book app to learn bash

I'm fairly proficient in C and Python, but want to learn some skills for administrating my new Linux machine. I wrote this simple address book app to teach myself shell scripting. This is the first ...
6
votes
2answers
2k 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. ...
6
votes
2answers
2k views

Very basic shell on microcontroller in C

Objective: A lightweight shell that runs on a microcontroller (MSP430) and parses incoming data into a command and additional parameters. Requirements: Support of quoting in ...
6
votes
1answer
465 views

Function to get specified key from /proc/cpuinfo

On Linux, the file /proc/cpuinfo returns a set of key-value pairs, where the key and value are separated by a colon and each pair has its own line. It's a bit more ...
6
votes
1answer
116 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 ...
6
votes
1answer
129 views

Install Python script requirements

Sometimes I download a Python script (from a trusted source), and can't run it because of missing dependencies, which I have to install one by one (no ...
6
votes
1answer
112 views

Pre-commit hook to prevent large file commits

I've written the below bash script to run as a pre-commit hook. The intention is to check the git staging area for any files larger than 1mb, and prevent the commit if any are present. ...
6
votes
1answer
58 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, ...

1
2 3 4 5 6