Skip to main content

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
2 answers
67 views

Using git autobackup with shell script

I have php website for prevent hacker modify any file and inject backdoor. I want to use git as a file tracking solution. This is my shell script: ...
Anas's user avatar
  • 139
2 votes
2 answers
50 views

Check if program has been installed successfully at a given path

The path is provided as an argument by a Makefile within an install target. The script verifies if the specified path is already included in the system's ...
Harith's user avatar
  • 9,777
2 votes
1 answer
140 views

Update a docker compose service properly

I'm currently running an executable in Docker that has been mounted as a Docker volume in the foreground. The executable (or the service) continuously generates console output and can be interrupted ...
Tobias Grothe's user avatar
0 votes
1 answer
34 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
2 answers
100 views

Script to prevent nested root shells (POSIX)

Script to prevent nested root shells shall do exactly as said, plus some niceties like an error message when someone runs it with some argument/option. ...
Vlastimil Burián's user avatar
3 votes
1 answer
48 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
146 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
407 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
33 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
126 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
86 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
37 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
  • 81.7k
3 votes
1 answer
67 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
102 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
542 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
130 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,589
4 votes
1 answer
56 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
133 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,184
1 vote
2 answers
103 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
118 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
243 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,137
6 votes
3 answers
778 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,137
2 votes
1 answer
52 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
63 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,137
0 votes
1 answer
52 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,137
4 votes
1 answer
125 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,137
2 votes
1 answer
58 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
  • 24.8k
1 vote
1 answer
70 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
139 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
32 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
3 votes
1 answer
67 views

Project setup script

It's a pretty simple script really. I just want to know if there is a way to improve it. ...
Nadpher's user avatar
  • 909
4 votes
1 answer
150 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
2 votes
1 answer
304 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
152 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
50 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
162 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
101 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
0 votes
0 answers
79 views

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 and I've tested it and it almost works. This was the ...
somethingSomething's user avatar
1 vote
1 answer
139 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
213 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
652 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
  • 767
3 votes
1 answer
145 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
132 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
4 votes
1 answer
61 views

Is device mounted? Both UUID and device names accepted

I am trying to write an 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
102 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
53 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
105 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.3k
2 votes
1 answer
76 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