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
2
votes
2answers
114 views

Shell command to output all plugins that exist across multiple wordpress installations

I'm working on a server and need a complete list of plugins that are installed for all wp installations. I only need to know whether a plugin exists or not, it doesn't matter where it exists. For ...
3
votes
1answer
49 views

Bulk File Rename

A function that funnels all filenames into a file and opens that file in vim. The user then changes the names, saves, and quits. Finally the function renames the files in the folder with the new names ...
2
votes
0answers
41 views

Code to backup the history file in Linux

How is the logic, efficiency and can it be improved? This is a snippet from my .bashrc file; I just wrote it and I've tested it and it almost works. This was the ...
1
vote
1answer
72 views

Bash Code to backup the history file in Linux [closed]

How is the logic, efficiency and can it be improved? This is a snippet from my .bashrc file, I just wrote it. The code is supposed to do this: Backup my ...
9
votes
2answers
826 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: ...
3
votes
2answers
65 views

POSIX shell function for asking questions

I've written a tiny function for asking questions intended for my POSIX shell scripts, where I often need user input. The function takes 2+ arguments, where: Is a string containing the question. , 3....
3
votes
1answer
61 views

checksum hash verification functions for bash scripts

just a little script, or a bit of a template of one that I used to submit an assignment. I believe it all works fine, I just wanted to give it to other people, and get some feedback on it; maybe make ...
3
votes
1answer
33 views

batch add users to nextcloud on docker with csv

I have a working script that will batch add users to an instance of nextcloud running on top of docker. This version is the result of changes made after asking this question. I guess I'm looking for ...
2
votes
1answer
84 views

Editing system files in Linux (as root) with GUI and CLI text editors

My intention is to POSIX-ly write one generalized function for running various text editors I use for different purposes through sudoedit, i.e. editing files as ...
3
votes
1answer
24 views

Is device mounted? Both UUID and device names accepted

I am trying to write is_device_mounted script, which in turn will serve a greater purpose in my home Linux system. It does not even have an error reporting ...
2
votes
2answers
47 views

Lock file and interrupt signals in POSIX shell script running indefinitely

This script is running indefinitely as the Linux background process. I have put an enormous effort to make this POSIX shell script containing an infinite loop shut down tidily along with the ...
2
votes
2answers
42 views

POSIX-ly finding a specific Java process

In this code I find a list all of the running java processes and give the below function a name to look for, it will do its best. But since I find my approach a ...
3
votes
1answer
57 views

Easy to use code preparation script for CodeReview questions

We all face questions that forget to include their code. Sometimes all of it, sometimes only parts, that make the rest of the question unfortunately incomplete and therefore off-topic. What if it was ...
1
vote
0answers
36 views

Interactive Linux upgrade script - Follow-up #1

One year ago I asked for a yearly revision of my Interactive Linux upgrade script. There is nothing new to the conditions, therefore please read the original question before you decide to comment and ...
0
votes
1answer
27 views

Shell POSIX OpenSSL file decryption script follow-up #3 (final)

From original very simplistic code: Shell POSIX OpenSSL file decryption script I learned a lot both from the first follow-up review, and the second one as well, many thanks! I just need one final ...
0
votes
1answer
46 views

Shell POSIX OpenSSL file decryption script follow-up #2

This question is the second follow-up of: Shell POSIX OpenSSL file decryption script The first follow-up was: Shell POSIX OpenSSL file decryption script follow-up #1 Both of which have proven very ...
3
votes
2answers
107 views

Generic error handler function for POSIX shell scripts

Intention I came with the idea of generic, portable, highly reliable, and further customizable function for Shell scripts, written in POSIX, for error handling. Purpose The function shall find out, ...
2
votes
1answer
50 views

Commit the working directory to different branch and switch back

The aim of this script is to snapshot the current working directory of a git repository to another branch. Afterwards, it switches back to the original branch and restores the original state, ...
1
vote
2answers
168 views

Long-term archiving + encrypting shell script

Yesterday, I very quickly, in an hour, wrote the very first version of my long-term archiving + encrypting shell script. I am aware it may have too many flaws, but none of them really prevent it from ...
7
votes
1answer
81 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
3answers
132 views

Arch linux installation script to be reviewed for any leakage of personal / security info

While I have been teaching myself a little about linux, it's boot processes and service configuration I have been using arch linux in virtualbox for my experimentation. Eventually after much wiling ...
5
votes
1answer
146 views

Lightshot Print Screen key linux handler - Follow-up #1

This question is a direct follow-up #1 of my previous question: Lightshot Print Screen key linux handler There were too many errors which I didn't see at the moment and I tried hard to fix them up ...
3
votes
2answers
67 views

Moving files and leaving links in bash

The objective of this code is to create a command that move files and leaves links in their place. I'm just a beginner in shell scripting and it would be quite useful to hear your opinions on how to ...
3
votes
3answers
52 views

Shell install.sh for repository (rpi_videoloop)

I've written my first installation script in shell and was wondering on how I can improve the install procedure to make it more clean? Here's the code: ...
2
votes
1answer
28 views

Finding (and counting) duplicate JS/Java files

I have the following script which takes minutes to give output. ...
3
votes
1answer
104 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
2answers
87 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 ...
0
votes
1answer
203 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
1answer
91 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
0answers
60 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
1answer
121 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
2answers
46 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: ...
5
votes
1answer
575 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
1answer
145 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 ...
3
votes
1answer
105 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 ...
4
votes
1answer
28 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
1answer
66 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
2answers
95 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 ...
5
votes
1answer
83 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
2answers
95 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
1answer
76 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 ...
4
votes
2answers
48 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 ...
2
votes
2answers
41 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
1answer
23k views

Replacing values in json file with jq

I have a JSON file like ...
5
votes
1answer
37 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 ...
4
votes
1answer
103 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 ...
1
vote
1answer
259 views

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

As root, run: ...
3
votes
1answer
32 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
1answer
99 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
1answer
109 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. ...