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
1 vote
2 answers
50 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 ...
2 votes
1 answer
30 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 ...
  • 65.4k
3 votes
1 answer
52 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 ...
  • 61
1 vote
1 answer
59 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 ...
5 votes
1 answer
209 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, ...
  • 53
2 votes
1 answer
54 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 ...
  • 9,249
4 votes
1 answer
53 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?&...
  • 882
4 votes
1 answer
113 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. ...
  • 1,036
1 vote
2 answers
77 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 "...
3 votes
1 answer
59 views

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

...
5 votes
1 answer
179 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 ...
  • 2,937
6 votes
3 answers
712 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,937
1 vote
1 answer
38 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
0 answers
30 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 ...
  • 2,937
0 votes
1 answer
38 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. ...
  • 2,937
4 votes
1 answer
92 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,937
2 votes
1 answer
48 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 ...
  • 20.8k
0 votes
1 answer
58 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 ...
4 votes
2 answers
115 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
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 ...
  • 21
4 votes
1 answer
112 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: ...
  • 1,717
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 ...
2 votes
1 answer
258 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
2 answers
134 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
0 answers
46 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
2 answers
134 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 ...
  • 168
3 votes
1 answer
92 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
0 answers
61 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
1 answer
115 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
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: ...
3 votes
2 answers
179 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
1 answer
348 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 ...
  • 739
3 votes
1 answer
114 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 ...
  • 183
2 votes
1 answer
108 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
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 ...
2 votes
2 answers
85 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
2 answers
47 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
1 answer
95 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 ...
  • 19.1k
1 vote
0 answers
42 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
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 ...
0 votes
1 answer
60 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
2 answers
300 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
1 answer
115 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, ...
  • 205
1 vote
2 answers
182 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 ...
8 votes
1 answer
109 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, ...
  • 1,785
6 votes
3 answers
239 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
1 answer
162 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
2 answers
92 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 ...
  • 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: ...
  • 143
2 votes
1 answer
31 views

Finding (and counting) duplicate JS/Java files

I have the following script which takes minutes to give output. ...