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
5 votes
1 answer
102 views

Replace version numbers in multiple files

In the script below I need to search in multiple files, and find a string, and replace with another. It's basically version numbers (which need incrementing). Every time I find the old version number, ...
user avatar
  • 53
2 votes
0 answers
16 views

Chaining perf with FlameGraph

This is my first serious shell script, so it is probably horrible. Problem statement I decided to improve my profiling skills as so far they were mostly about hand-rolling counters and timers. After ...
user avatar
  • 9,039
4 votes
1 answer
50 views

Whose `git` is it anyway?

A Posix function for finding the nearest parent file. For example "what .git/ am I working in?" or "is there an .npmrc affecting npm from this path?&...
user avatar
  • 882
4 votes
0 answers
34 views

Shell script to download Project Euler problems and combine to PDF

This is a script I created that downloads Project Euler webpages and combines them to PDF. The script also downloads animated files. ...
user avatar
  • 798
1 vote
2 answers
68 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 "...
user avatar
3 votes
1 answer
36 views

Short (user)script to store current URL and close tab in qutebrowser

...
user avatar
4 votes
1 answer
130 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 ...
user avatar
  • 2,897
6 votes
3 answers
698 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) ...
user avatar
  • 2,897
2 votes
0 answers
50 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 ...
user avatar
  • 2,897
1 vote
1 answer
30 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(...
user avatar
2 votes
0 answers
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 ...
user avatar
  • 2,897
0 votes
1 answer
34 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. ...
user avatar
  • 2,897
3 votes
1 answer
71 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 ...
user avatar
  • 2,897
2 votes
1 answer
46 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 ...
user avatar
  • 18.2k
0 votes
1 answer
53 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 ...
user avatar
2 votes
1 answer
77 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, ...
user avatar
2 votes
0 answers
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 ...
user avatar
  • 21
2 votes
0 answers
65 views

Re-interpolating a value from jq back into jq

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

sudoedit_enhanced written POSIX-ly (readlink possible problem?)

sudoedit_enhanced written POSIX-ly challenge While creating sudoedit_enhanced POSIX (apart from ...
user avatar
2 votes
1 answer
188 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 ...
user avatar
1 vote
2 answers
125 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 ...
user avatar
2 votes
0 answers
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 ...
user avatar
2 votes
2 answers
126 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 ...
user avatar
  • 148
3 votes
1 answer
77 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 ...
user avatar
2 votes
0 answers
56 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 ...
user avatar
1 vote
1 answer
110 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 ...
user avatar
9 votes
2 answers
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: ...
user avatar
3 votes
2 answers
157 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....
user avatar
3 votes
1 answer
205 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 ...
user avatar
  • 729
3 votes
1 answer
96 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 ...
user avatar
  • 183
2 votes
1 answer
107 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 ...
user avatar
3 votes
1 answer
28 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 ...
user avatar
2 votes
2 answers
75 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 ...
user avatar
2 votes
2 answers
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 ...
user avatar
3 votes
1 answer
91 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 ...
user avatar
  • 18.8k
1 vote
0 answers
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 ...
user avatar
0 votes
1 answer
45 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 ...
user avatar
0 votes
1 answer
58 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 ...
user avatar
3 votes
2 answers
221 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, ...
user avatar
2 votes
1 answer
65 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, ...
user avatar
  • 205
1 vote
2 answers
178 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 ...
user avatar
7 votes
1 answer
95 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, ...
user avatar
  • 1,765
6 votes
3 answers
226 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 ...
user avatar
5 votes
1 answer
158 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 ...
user avatar
3 votes
2 answers
86 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 ...
user avatar
  • 41
3 votes
3 answers
61 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: ...
user avatar
  • 143
2 votes
1 answer
30 views

Finding (and counting) duplicate JS/Java files

I have the following script which takes minutes to give output. ...
user avatar
3 votes
1 answer
147 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, ...
user avatar
5 votes
2 answers
119 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 ...
user avatar
0 votes
1 answer
582 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. ...
user avatar