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
0
votes
0answers
14 views

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

One year and a half ago I posted the second iteration of this script for a review here: Editing system files in Linux (as root) with GUI and CLI text editors #2 Since then, it has been "...
2
votes
1answer
21 views
4
votes
1answer
97 views

Generating a domain and IP blacklist with Bash

This is a project to pull domain & IP blacklists from various sources and compile them into one list. There are some whitelists included that are applied when a blacklist is built. It draws ...
6
votes
3answers
677 views

Updating text in a HTML document with Bash

This is a small script to update my project's README file. Notes on improvements from any aspect are welcome! Here is the document it updates. readme.sh (Executed like so: ./readme.sh) ...
2
votes
0answers
46 views

The Blacklist v2

This script gathers domains listed from sources in this JSON file and compiles them into one text file. Text files that have a similar key under the whitelists ...
1
vote
1answer
27 views

Testable and self-contained bash script

I wrote a short bash script for a completion check of downloading images. goal of this code (Added) I have some downloading content directories. Each of them has a script for downloading images(...
2
votes
0answers
29 views

The Blacklist -- Follow-Up 2: Electric Boogaloo

One of my main goals regarding this script has been to figure out a way to use the "adblock.sources" file available on its main repository and not my fork. That version has some syntax ...
0
votes
1answer
33 views

The Blacklist - follow-up

Follow-up from this question using @Toby Speight's answer: The primary concern is jq improvement/optimization, but please detail any others. ...
3
votes
1answer
51 views

The Blacklist: Blocking Malicious domains using Bash

I've made this script to automate blocking some deviant hosts on my router, and was curious if there's anything much else that can be done to make it quicker and more efficient. Presently I'm ...
2
votes
1answer
41 views

Portable Build System for Virtual Machine with Editor and Unit Tests

I am automating the building and unit testing of a personal project using shell scripts , CMake and make on the latest version of Fedora Linux. I have also tested building on the latest version of ...
0
votes
1answer
42 views

Attempt on basic input validation and functional programming in a POSIX shell

In spite of all the POSIX shell disadvantages, I am still sticking with it and I love its portability. Recently, I was searching for a way of code re-use, which turns out to be structured programming ...
2
votes
1answer
66 views

*nix, *bsd, etc basic `tput` color setup

My goal with the below piece of POSIX shell code was to address the more platforms the better with shell tput colors. With this code, I now start all of my scripts, ...
2
votes
0answers
29 views

sh script to open related URL based on possible nicknames

I'm new to sh and I would like to get feedback on how I can improve my code. The purpose is simple; I want to open the Jenkins JOB related to a service based on its possible aliases. If I map a ...
2
votes
0answers
28 views

Re-interpolating a value from jq back into jq

I have an almost-json document in a file named "versions.json" like this: ...
1
vote
0answers
42 views

sudoedit_enhanced written POSIX-ly (readlink possible problem?)

sudoedit_enhanced written POSIX-ly challenge While creating sudoedit_enhanced POSIX (apart from ...
2
votes
1answer
132 views

POSIX shell function to "dump" all given arguments

My today's idea was to create a POSIX shell function to dump all given arguments, typical use would be to call it from a fucntion, where you already know some arguments are not well set (empty; not ...
1
vote
2answers
101 views

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

This is the second iteration of this question A note to start with: the first iteration of this question can be found here: Editing system files in Linux (as root) with GUI and CLI text editors As ...
2
votes
0answers
43 views

Outputting a standalone shell script from arguments

I am solving an exercise. Essentially, it's a shell script that takes in file and/or directory arguments and outputs another (standalone) shell script that outputs these files, including any directory ...
2
votes
2answers
124 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
63 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
48 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
106 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
2k 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
101 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
123 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
76 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
101 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
25 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
67 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
43 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
85 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
41 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
41 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
53 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
156 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
52 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
175 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
89 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
205 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
154 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
83 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
57 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
29 views

Finding (and counting) duplicate JS/Java files

I have the following script which takes minutes to give output. ...
3
votes
1answer
133 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
111 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
473 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
117 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
63 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
183 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
50 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: ...