Questions tagged [shell]

The term 'shell' refers to a general class of text-based command interpreters most often associated with the Unix & Linux operating systems.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
29 views

Tor Relay Startup Script for New Server [closed]

I created a shell script that I can pull and run to set up a new server to run a tor relay. Everything seems to work fine, but it install an obsolete version of tor (Tor 0.4.2.7). I have tried to ...
yololantern's user avatar
7 votes
2 answers
230 views

A simple shell in C

The M-Shell (msh) provides a basic command-line interface similar, and features some builtins (cd, exit, help, whoami, kill). ...
Harith's user avatar
  • 4,185
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
-1 votes
1 answer
34 views

how to boost my script in fault tolerance ,performance and readability [closed]

...
xwj's user avatar
  • 9
1 vote
2 answers
67 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
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
132 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
1 vote
1 answer
64 views

VSCode-Portable Updater (MSYS2)

VSCode's portable mode doesn't support auto-updates, unlike its normal installer-based versions. I happen to use MSYS2's UCRT64 environment which makes the Linux tools I like play nice with the ...
404 Name Not Found's user avatar
5 votes
1 answer
103 views

Script to loop through a list of YouTube channels, and output metadata to a Markdown file

Overview I have created a bash script (triggered via GitHub Actions) that does the following: Parse a list of YouTube channel IDs and nicknames. Fetch their metadata via YouTube's Channel API. Build ...
Jake Lee's user avatar
  • 153
2 votes
1 answer
111 views

Generate a valid private key from public key

Given a public key, I want to generate a corresponding private key. I know this will take at least decades or centuries on average to achieve. I am wanting to increase performance as my current code ...
hflvegmnc's user avatar
2 votes
1 answer
34 views

Improving Shell Installation Script

I'm currently working on a project and currently have this code. I already improved it by having some pointers, but I want to make it more professional looking and right. What should I implement next? ...
user avatar
7 votes
2 answers
2k views

Shell script to compile Java

...
user16217248's user avatar
0 votes
1 answer
41 views

Printing script intro by typing Y/y or just by pressing Enter in a POSIX shell script

Say, I have my POSIX script introduction stored in variable: ...
Vlastimil Burián's user avatar
4 votes
1 answer
133 views

Creating ZFS-based rootfs for installing Linux in Bash

I've written a bash script that creates a root filesystem on ZFS for installing Debian or Arch. The purpose of this script is to make it easier installing e.g. Arch without the need to make a ZFS pool ...
whiteman808's user avatar
0 votes
0 answers
48 views

Shipping dependencies (dynamic libraries) with an executable build under Mac OS with Crystal-lang

I am looking for a way to ship dependencies (dynamic libraries) with an executable build under Mac OS with Crystal-lang, is there a way to improve on: It seems to works, but it is a bit of a hack. <...
Serge Hulne's user avatar
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.6k
8 votes
3 answers
375 views

Print full path to last modified file in a given location

Background I've provided two simple functions that I use to print a full path to the last modified file within a directory. I don't code in bash frequently so I'm looking for a generic feedback on ...
Konrad's user avatar
  • 323
1 vote
1 answer
57 views

Changing file encoding, removing mid-line LF, and converting DOS CR-LF to Unix LF

We have several thousand large (10M<lines) text files produced by a windows machine. We need to change the file encoding of these files from cp1252 to ...
rxFt20's user avatar
  • 113
2 votes
2 answers
49 views

Archive, compress, remove old archive file then remove source file if below set size

I'm working on a script that will archive, compress, clear old archive files, then remove the source file if it is below a set size. The output when I tested it worked, but I just wanted a second ...
Brad Barnes's user avatar
6 votes
2 answers
620 views

Extract data from api using shell scripting

So we have many vlans at work, often it is nice to see which ip ranges are associated with said vlan. We have a well developed api for displaying information about our network and thus I wrote a small ...
N3buchadnezzar's user avatar
4 votes
3 answers
346 views

A shell script to get the current battery status

Is this code well written? I'm not doing much, just rendering my battery status for my status bar but the code seems pretty long. I am new to Bash and Linux, so I thought this code could be improved ...
Diwas10's user avatar
  • 111
3 votes
2 answers
417 views

Bash script using SSH to sum disk usage on NetApp

I have tried to come with below bash script which is at least working for me, i know its not perfect and that why i want some review and suggestion to make it more aligned with bash practices. I'm ...
user294110's user avatar
1 vote
1 answer
157 views

Shell implementation in C

I made a small shell implementation in C. It reads stdin and executes the command. It can also take in a file name from argv and execute all the arguments in the ...
elonma1234's user avatar
1 vote
1 answer
89 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
488 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
29 views

Shell script to backup db from mysql whether the mysql server is running in docker

I have written this shell script to backup MySQL database to disk. It works fine but I am not well proficient in shell scripting. So what do you think can it be improved? ...
Chang Zhao's user avatar
3 votes
1 answer
255 views

C implementation of a minimal shell

I wrote a program that implements a minimal shell and reads from standard input commands and executes them. Is my implementation ok? I admit that I helped myself a lot with google. Could I have ...
Mark's user avatar
  • 449
3 votes
2 answers
163 views

Is this implementation of the `mv` command the most appropriate? It can be improved?

I wrote a program that implements the same function as the mv command. I know this is not the best implementation, so I would like some suggestions for improvement, ...
Mark's user avatar
  • 449
-2 votes
1 answer
129 views

Write portable Git aliases

The following aliases return all the same number of results, on my Cygwin (on Windows): ...
user3341592's user avatar
4 votes
1 answer
87 views

Recursively Copy Dotfiles from Git Repo to New System's Home Directory

I manage my dotfiles in a github repo. The idea would be that I could clone the repo if I ever have to develop on a new system and symlink them to the home ...
Jordan Mandel's user avatar
0 votes
1 answer
748 views

Bash script to process Kafka messages

I want to use shell scripts to consume kafka messages and return to status. I found that my script wasn't efficient enough. Can I write this script better? I want to output kafka-console-consumer.sh ...
Echo_s's user avatar
  • 9
4 votes
1 answer
121 views

zsh function for shrinking $PWD with $HOME replacement

I wanted a $PWD shrinking for my $PROMPT with the following requirements: $HOME is replaced ...
kikito's user avatar
  • 186
5 votes
1 answer
217 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
3 votes
1 answer
141 views

Parse log file and send the result to an API

The task is to get the most recent login time of the day for each user. Then send such a result to an API. The log file (file.log) looks like the following (only ...
Marc's user avatar
  • 5,522
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
6 votes
4 answers
458 views

Interactive shell for Arduino

Goal I needed to interact with microcontrollers (ESP8266 & ESP32) via the Serial interface, so I wrote a small interactive shell with the command pattern. The defined commands can either accept no ...
Eric Duminil's user avatar
  • 3,960
8 votes
1 answer
2k views

Parsing and Simple Shell in C

I wrote this simple shell in C for a university assignment on operating systems (My guess is that it's just the beginning and the next assignments will add to this code). The program prints the prompt ...
RedYoel's user avatar
  • 311
3 votes
1 answer
361 views

Bash Script for healthcheck linux

I have below bash script which i have written to check the health of different storage component and then creates an incident through service-now tool. This is script is working fine for me but i ...
user2023's user avatar
1 vote
1 answer
50 views

Small bash script to quickly edit scripts in $PATH

Staying true to the mantra: "The third time you do something, you automate", I've built up a decent collection of shell scripts that live in ~/bin. Some ...
Elias Van Ootegem's user avatar
0 votes
1 answer
101 views

Dirty Bash hack to run the ssh connections in the Parallel mode

A Few years back I used to opt the below method to run the shell program in a Parallel way to open multiple ssh session at a time to get a quick result. I know there are various other good utilities ...
Karn Kumar's user avatar
3 votes
1 answer
293 views

Bash script for log rotation

Okay, first things first: Yes, I am aware of the logrotate tool, which would usually be used for something like this. However, since the logfile i want to rotate already contains a timestamp in the ...
Felix G's user avatar
  • 133
2 votes
1 answer
54 views

Bash - Automating creation of test files

I'm in the process of understanding shell scripting - this is my simple code for adding test files for python unittest I'm looking for best practice pointers, variable naming, and of course comments ...
Edwin Carlsson's user avatar
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.8k
5 votes
1 answer
108 views

How to put apt and python packages in a list and check if installed or not then install

I am not an expert in shell scripting, I need help optimizing the shell script I wrote, This shell script I wrote is run by users on the client side who connect to our vpn server from the setting ...
Chang Zhao's user avatar
5 votes
2 answers
375 views

c++ shell for linux

...
The Masked Rebel's user avatar
2 votes
1 answer
36 views

Expect script that tests if a passwordless connection is setup

I have written a simple expect script to tell me if a passwordless connection is set up. ...
harleypig's user avatar
  • 217
2 votes
2 answers
77 views

Reading input keys from a shell

I was cleaning up some old code and came across this (it's to read input from a terminal): ...
clankill3r's user avatar

1
2 3 4 5
7