Questions tagged [sh]

sh, aka Bourne Shell, is the Unix Shell, the standard shell since v7 Unix. POSIX has standardized the shell, and portable shell scripts should conform to /bin/sh syntax.

Filter by
Sorted by
Tagged with
3 votes
1 answer
158 views

Lightshot Print Screen key linux handler

I haven't found any Lightshot Print Screen key linux handler publicly available. So, I decided to write one today. It is a standard POSIX shell script. I believe there is always space to get better, ...
5 votes
2 answers
125 views

Goodgame Empire coin collector with random offsets in (almost-POSIX) Bash

Today, my goal was again to improve my POSIX shell scripting abilities. In one MMO game called Goodgame Empire, there is possible to code yourself a coin (tax) collector. But that's of less ...
1 vote
1 answer
746 views

POSIX shell script for generating pseudo-random numbers

My today's goal was to further practice POSIX shell scripting. So, I decided to write the following POSIX shell script for generating pseudo-random numbers. Any and all reviews would be appreciated. ...
1 vote
1 answer
143 views

Shell POSIX OpenSSL file decryption script follow-up #1

This question is the first follow-up of: Shell POSIX OpenSSL file decryption script Please read it before you continue reading this. Thank you. I only have one new problem solved and I would like ...
2 votes
0 answers
70 views

Shell script to manage passwords

To get my feet wet with shell scripting I wrote this "minimal command line password manager" (aka pwm) taking inspiration from the well known ...
5 votes
1 answer
208 views

Interactive Linux upgrade script

One year ago, I asked for a review of Simple Linux upgrade script in Bash. Conditions are slightly changed, and/or more accurate: Code readability for the code user, making it simple to adjust the ...
2 votes
2 answers
61 views

How long a PID has been running (taking multiple inputs)

Tonight I tried to write a POSIX shell script which would allow me to check how long a process is running (via it's ID) and be able to handle multiple inputs: ...
6 votes
1 answer
887 views

Shell POSIX OpenSSL file decryption script

Tonight, I tried to write a Bash OpenSSL file decryption script. Encryption script will follow in highly similar manner, so I think it's not necessary now. Let's suppose we have an encrypted large ...
2 votes
1 answer
251 views

Shell script to create a boilerplate proyect

This is actually my first shell script and just by looking at it I know this can look better. I use Elixir and Phoenix for most of my projects and I started using Zurb Foundation 6, changing from ...
  • 147
3 votes
1 answer
252 views

Shell script for reading /etc/passwd into SQLite

I want to read 4 columns, namely UID, GID, username and home directory of specific users from /etc/passwd into an SQLite database. I found this to create many ...
  • 31
4 votes
1 answer
34 views

Alternative to env that accepts arguments

It is commonly known that env does not allow passing of arguments - at least not reliably. There are various workarounds described here, but they felt to hacky and ...
3 votes
1 answer
76 views

Query database and check server details

I have written bash script to query database and check server details. Please let me know if the script is as per best standards: ...
6 votes
2 answers
123 views

A replacement for OSX's path_helper

I was having problems setting my path the way I wanted, I turned to Apple's path_helper but found it appends system dirs to the beginning of the path. I found someone had made a start on a replacement ...
  • 240
5 votes
1 answer
129 views

trash script to alias rm

This script implements a command line level trashcan system. Designed to work around rm doing the bits needed to implement a trashcan system at command line level....
3 votes
2 answers
140 views

Bash script to rename subfolder to include name of parent folder

Here's the current structure of my directory. . ├── Show 1 │   ├── Season 1 │   └── Season 2 ├── Show 2    ├── Season 1     └── Season 2 I want to rename the ...
2 votes
1 answer
92 views

Random password generator sh script

Yesterday, I was bored and decided to write a random password generator. At first it used numerous temporary files, changed that by using arrays. This was written on OS X and should work on Linux ...
  • 85
4 votes
2 answers
56 views

Process monitoring script

I wrote a script which logs memory usage of a process (pid in file), and reacts in case a limit is reached. I run the script nightly. In my case, the process concerned propably has a memory leak and ...
  • 245
2 votes
2 answers
47 views

High CPU utilisation for Logs Manager shell script

I have written a shell script to manage the tcpdump pcap logs and syslog files in my Linux board, so as to maintain the disk usage to maximum of 70%. The script checks for the disk usage every ...
6 votes
1 answer
40k views

Replacing values in json file with jq

I have a JSON file like ...
  • 213
5 votes
1 answer
48 views

Script to record an inventory of a backup

This is a script designed to make an inventory file which records the contents of a directory allowing verification that a backup has the same data. The same script can also A full github repo is ...
  • 425
4 votes
1 answer
122 views

Simple import system for a large shell program

I am writing a large shell program comprised of several source files. I was looking for a basic import system that accomplishes three goals. Avoid sourcing entire files for access to just a few ...
  • 261
1 vote
1 answer
270 views

Disable reboot on control-alt-delete for RedHat/CentOS 5/6/7

As root, run: ...
  • 131
3 votes
1 answer
41 views

Displaying a table of shell aliases

I'm just getting into bash and sh scripting. I mostly just stub out little convenience or exercise scripts for myself, but I recognize I may be flaunting best practices at times. My question is ...
2 votes
1 answer
267 views

POSIX shell script using a string to store command arguments

Background I’ve started putting all my configuration files (which include many shell files) under version control. In the Git repository, I’ve configured a pre-commit hook that runs the ...
1 vote
1 answer
118 views

Sh script to reduce version number in opkg status file

I have written a script to reduce/lower the version number stored in opkg status file using small shell script, This will enable us to force the opkg to install same version of a Debian package again. ...
  • 241
6 votes
2 answers
81 views

An installer for shell scripts, written in pure sh

I wrote a tiny shell script that basically installs a script into your system by copying it to someplace like /usr/local/bin, chmodding it, and adding it to your ...
  • 449
2 votes
2 answers
104 views

Split redirecting to multiple files in bash

A function mycommand which runs command and: Gives me three log-files which are: *.stdout.log: everything from ...
  • 869
10 votes
1 answer
172 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 ...
4 votes
3 answers
128 views

Shell script to detect router slider status

I have an openwrt router (TP-Link MR3040) and on boot I have it check the slider (AP, WISP, 3G/4G mode). The goal was to have it execute the current "slider status" vs the old one, or do nothing if it'...
  • 181
9 votes
2 answers
817 views

Fizz having an argument with Buzz

For my current project I need to validate responses. The requests will be send from multiple different shell scripts and should be controlled from another script. I'd never targeted a ...
  • 13k
4 votes
3 answers
892 views

Bash script that checks if font is installed and installs it if necessary

This checks if a font is installed by using fc-list and grep. If the particular font is not installed, it offers to install it ...
  • 175
3 votes
1 answer
1k views

Bash script that checks for package dependencies and installs them if necessary

I'm new to writing bash scripts and was wondering if I could get someone's advice on a part of the script I'm working on. Intended purpose of code Check if a package exists using ...
  • 175
3 votes
1 answer
220 views

A minimal init script

I tried looking up some good example init scripts, but all that I found were excessively complicated. So I wrote my own simple init script targeting CentOS 6. I tried to follow LSB where I understood ...
6 votes
3 answers
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
2 answers
154 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. ...
  • 61
2 votes
0 answers
114 views

Script to configure Synaptics touchpad

I have a shell script to configure Synaptics touchpad settings at login. Background You configure the touchpad with the synclient command. Its usage is ...
  • 1,169
4 votes
1 answer
174 views

Shell script for creating CR questions

Inspired by Tool for creating CodeReview 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 stdout:...
  • 4,531
8 votes
3 answers
182 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 ...
  • 83
8 votes
2 answers
9k 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 ...
  • 81
4 votes
1 answer
224 views

Mount different remote systems

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 ...
5 votes
3 answers
427 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 ...
8 votes
5 answers
1k views

Shell script to download and extract a tarball from GitHub

I don't want anything to execute if any preceding step fails: ...
  • 732

1
2