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
1 answer
25 views

Yet another sh script to backup one directory

A single directory should simply be backed up with the zip tool, and the time of the backup should be preserved in the file name. I have written a Posix shell script for this. Can this script simply ...
Tobias Grothe's user avatar
2 votes
1 answer
44 views

Debian and Docker compose upgrade script, 2nd version

As a continuation of this question, I would like a second review from you. Here is the updated sh script: ...
Tobias Grothe's user avatar
3 votes
1 answer
130 views

Debian and Docker compose upgrade script

I'm running Debian 12 and Docker compose containers. Once a day, crontab should start the script, but the script should also be called manually. Could you rate my upgrade script file or recommend an ...
Tobias Grothe's user avatar
12 votes
3 answers
1k views

Blog site generator written in shell script

Since I am not a fan of having using large web-frameworks and libraries just to setup a simple blog, I decided to write my own static blog site generator in pure shell script. The script uses pandoc, ...
766F6964's user avatar
  • 901
2 votes
1 answer
305 views

Shell script to download multiple files from different URL's using for loop to download and verify files on each invocation

The expected behavior of the script is to download a file from a URL if the file is not present in the current directory and compare the md5 checksum of the file against the md5 checksum from the ...
Chris Stone's user avatar
1 vote
0 answers
29 views

For loop to download files once and verify them on each invocation [duplicate]

The complete script works as expected. I am able to download and verify the files. If the file is all ready present verification is retested and downloads if necessary. I'm in the process of teaching ...
Chris Stone's user avatar
2 votes
2 answers
123 views

Linux Script Set Permission Function

I wrote a simple script to set permissions for a file or folder for some embedded Linux devices as part of a larger setup script. This method would be called on less than 20 files and folders. It ...
netcat's user avatar
  • 203
1 vote
2 answers
71 views

Shell script to download, compile and run Analog Clock in AEC

As some of you know, I have made a programming language, called AEC, and written two compilers for it, one targetting x86 and other targetting WebAssembly. Recently, I have tried to write two shell ...
FlatAssembler's user avatar
2 votes
1 answer
32 views

Find first or last argument lexicographically or temporally

I often find I need to find the earliest or latest file matching a given pattern, and sometimes to choose the lowest or highest string from several possibilities. The following four functions provide ...
Toby Speight's user avatar
  • 74.4k
3 votes
1 answer
60 views

PDFcomp: A PDF comprimer easy script

I developed this script in dead time to be able to compress the PDFs that they send me to university and also to be able to send scans to the various institutions that require formats that do not ...
NFVblog's user avatar
  • 61
1 vote
1 answer
86 views

Lexer for shell-like language [rust]

I am working on writing a rust implementation of a sh-like language. Rather than posting 600 lines of code here, you can just go to the GitHub repository. Is this a ...
CATboardBETA's user avatar
5 votes
1 answer
479 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, ...
nszmmp's user avatar
  • 53
2 votes
1 answer
110 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 ...
Incomputable's user avatar
  • 9,424
4 votes
1 answer
55 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?&...
psaxton's user avatar
  • 892
4 votes
1 answer
125 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. ...
qwr's user avatar
  • 1,016
1 vote
2 answers
93 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 "...
Vlastimil Burián's user avatar
3 votes
1 answer
104 views

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

...
Carla only proves trivial prop's user avatar
5 votes
1 answer
216 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 ...
T145's user avatar
  • 3,087
6 votes
3 answers
751 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) ...
T145's user avatar
  • 3,087
1 vote
1 answer
44 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(...
Haruo Wakakusa's user avatar
4 votes
1 answer
53 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 ...
T145's user avatar
  • 3,087
0 votes
1 answer
44 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. ...
T145's user avatar
  • 3,087
4 votes
1 answer
112 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 ...
T145's user avatar
  • 3,087
2 votes
1 answer
52 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 ...
pacmaninbw's user avatar
  • 23.7k
0 votes
1 answer
65 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 ...
Vlastimil Burián's user avatar
4 votes
2 answers
130 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, ...
Vlastimil Burián's user avatar
2 votes
0 answers
30 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 ...
Pereira's user avatar
  • 21
4 votes
1 answer
137 views

Find download URL for a package, from almost-JSON with substitutions

I have an almost-JSON document in a file named versions.json. It looks like this: ...
kojiro's user avatar
  • 1,767
1 vote
0 answers
44 views

sudoedit_enhanced written POSIX-ly (readlink possible problem?)

sudoedit_enhanced written POSIX-ly challenge While creating sudoedit_enhanced POSIX (apart from ...
Vlastimil Burián's user avatar
2 votes
1 answer
297 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 ...
Vlastimil Burián's user avatar
1 vote
2 answers
147 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 ...
Vlastimil Burián's user avatar
2 votes
0 answers
47 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 ...
Elena Andreea Abig's user avatar
2 votes
2 answers
157 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 ...
mrmadhat's user avatar
  • 148
3 votes
1 answer
98 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 ...
Toni Jarjour's user avatar
2 votes
0 answers
70 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 ...
somethingSomething's user avatar
1 vote
1 answer
130 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 ...
somethingSomething's user avatar
9 votes
2 answers
3k 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: ...
Chau Giang's user avatar
3 votes
2 answers
205 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....
Vlastimil Burián's user avatar
3 votes
1 answer
542 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 ...
voices's user avatar
  • 749
3 votes
1 answer
134 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 ...
quarterpi's user avatar
  • 183
2 votes
1 answer
124 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 ...
Vlastimil Burián's user avatar
3 votes
1 answer
31 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 ...
Vlastimil Burián's user avatar
2 votes
2 answers
96 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 ...
Vlastimil Burián's user avatar
2 votes
2 answers
50 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 ...
Vlastimil Burián's user avatar
3 votes
1 answer
101 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 ...
Zeta's user avatar
  • 19.2k
1 vote
1 answer
65 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 ...
Vlastimil Burián's user avatar
0 votes
1 answer
47 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 ...
Vlastimil Burián's user avatar
0 votes
1 answer
65 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 ...
Vlastimil Burián's user avatar
3 votes
2 answers
466 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, ...
Vlastimil Burián's user avatar
2 votes
1 answer
244 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, ...
danijar's user avatar
  • 205