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
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
1 vote
1 answer
21 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? ...
user avatar
3 votes
1 answer
135 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 ...
user avatar
  • 1
3 votes
2 answers
94 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, ...
user avatar
  • 1
-2 votes
1 answer
108 views

Write portable Git aliases

The following aliases return all the same number of results, on my Cygwin (on Windows): ...
user avatar
4 votes
1 answer
47 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 ...
user avatar
0 votes
0 answers
23 views

Shell script to invalidate AWS cache

I made this script to invalidate AWS cache. The purpose of this script is to retry the command multiple times because we make a lot of invalidations and we often reach the number of concurrent ...
user avatar
0 votes
1 answer
47 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 ...
user avatar
  • 9
4 votes
1 answer
60 views

zsh function for shrinking $PWD with $HOME replacement

I wanted a $PWD shrinking for my $PROMPT with the following requirements: $HOME is replaced ...
user avatar
  • 176
0 votes
0 answers
18 views

Where and how can I speed up this config-driven ezstream script?

I've put together this script to check through various location and pick the next media file to play on an internet radio station: ...
user avatar
  • 101
0 votes
0 answers
50 views

displaying contents from CSV files in an HTML table

I'm pretty new to programming and shell and I'm not having any issue with the script below; it's working perfectly but I want to know if I can do better. I'm inserting the content of some CSV files (<...
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
3 votes
1 answer
65 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 ...
user avatar
  • 5,487
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
72 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
7 votes
4 answers
272 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 ...
user avatar
  • 3,948
5 votes
1 answer
622 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 ...
user avatar
  • 181
3 votes
1 answer
133 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 ...
user avatar
  • 53
0 votes
1 answer
35 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 ...
user avatar
0 votes
1 answer
80 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 ...
user avatar
3 votes
1 answer
47 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 ...
user avatar
  • 133
2 votes
1 answer
45 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 ...
user avatar
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
5 votes
1 answer
59 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 ...
user avatar
5 votes
2 answers
283 views

c++ shell for linux

...
user avatar
2 votes
1 answer
28 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. ...
user avatar
  • 217
2 votes
2 answers
55 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): ...
user avatar
5 votes
1 answer
70 views

Bash Code optimization For ssh login on the remote device

I have below code which works fine as its written in bash, i am just posting it here to see if this can be better optimised as per the BASH way. I am have an ...
user avatar
5 votes
1 answer
283 views

Fishy password management

Problem When it comes to security I like to don a tin foil hat. As such I use the, off-line password manager, Keepass. Keepass allows you to to use multi-factor authentication via; a password, a ...
user avatar
1 vote
0 answers
33 views

Project setup script

It's a pretty simple script really, i just want to know if there is a way to improve it. ...
user avatar
  • 879
2 votes
1 answer
52 views

Feedback on my bash backup script

I have this little server at home, which is hosting some websites, school stuff and a minecraft server. I made this backup script and I would like some feedback since I'm not very good at scripting. <...
user avatar
1 vote
0 answers
13 views

Compressing and encrypting file systems for backups

I am currently backing up remote OS' while preserving the permissions using rsync: rsync -aAX --numeric-ids --delete ... root@X.X.X.X:/ /backup/server/ Now I ...
user avatar
  • 237
3 votes
0 answers
71 views

Systemctl services start and UFW ports allow script

I made a script to start something akin to a "session" in which I start services and open tcp and udp ports in the firewall in order to work with, for example, a full stack project, and stop and close ...
user avatar
3 votes
1 answer
40 views

Check shell programs for portability

There are lots of shell programs that have /bin/sh as interpreter, yet use some features that are specific to bash or other popular shells. I have written a little ...
user avatar
  • 20.9k
4 votes
2 answers
524 views

A PHP script used on my home server to download YouTube videos

I have a PHP page I used to download YouTube videos, hosted on my Pi 4. The site is only going to be used on my home network (so a dot local address), but it allows me to download videos on my phone ...
user avatar
6 votes
2 answers
1k views

Test to see if installed and if not, install it

Okay all you Linux/shell folks out there. This is my first shell script (2nd if you count "Hello World") and would appreciate some feedback. Basically, I need to test whether ...
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
3 votes
1 answer
80 views

Compare and Process Common and Uncommon files separately

I have the following files: STUDENT_D19001.T103412_HU.txt STUDENT_D19001.T103412_KU.txt STUDENT_D19002.T113030_HU.txt STUDENT_D19002.T115055_KU.txt STUDENT_D19003.T115055_KU.txt STUDENT_D19004....
user avatar
  • 41
5 votes
1 answer
269 views

Bash script to check available name in Github

I just wrote this script to check if the name (that has 2 characters: 1 alphabet and 1 number) in Github is available or not so I can accompany this name. Here is my script: ...
user avatar
5 votes
1 answer
79 views

Downsample fastqs

I'm working on a project to downsample some fastqs (files that contain sequences). Each line of the fastq bioinformatics format comprises 4 lines chunks (id, dna sequence, "+", quality ...
user avatar
5 votes
1 answer
122 views

Bash script for speedreading training

I have coded a speedreading training bash script. My targed was to make some experience with bash in a funny way. It ...
user avatar
  • 497
2 votes
3 answers
89 views

Non-recursively replace all uppercase letters in files within current directory with lowercase letters - without looping

Let's say that I have a directory that looks like this: dir | File1.txt | fILE2.md | file3.tex When I execute my bash script from within the dir ...
user avatar
  • 169
6 votes
1 answer
147 views

Pre-commit hook to prevent large file commits

I've written the below bash script to run as a pre-commit hook. The intention is to check the git staging area for any files larger than 1mb, and prevent the commit if any are present. ...
user avatar
3 votes
0 answers
33 views

NRPE script for monitoring filesystems usage

Next script returns NRPE friendly output. It checks percentage usage of all local filesystems. Desired output if everything is ok: OK | /=56;;;; /boot=20;;;; /opt=40;;;; /var=60;;;; (and ...
user avatar
3 votes
1 answer
31 views

Running a shell command when a file is added to FTP on Linux Ubuntu

I've recently set up a continuous integration pipeline to deploy a .NET Core application to my Linux machine living on the cloud. My CI pipeline publishes my application, (specifically a .NET web ...
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
7 votes
3 answers
517 views

Inserting command output into multiline string

I'm writing a bash script to that picks up a user password from an environment variable, hashes this, and inserts the results into a postgres database. What I have works and looks fairly readable to ...
user avatar
  • 223
3 votes
1 answer
206 views

Shell script to set up Ant targets and properties for a new project

I've written this shell script to place Ant build.xml and build.properties into my project directory. It takes two options, one which ensures the project is set up for JUnit test compilation/running. ...
user avatar
  • 33
2 votes
3 answers
50 views

Write directory new entries to file periodically, keeping the ones that existed in the past

Some backup Bash script on my machine copies a specific directory entries filenames into a text file. Entries that no longer exist have to be kept (entries added during a previous run). The script ...
user avatar
  • 145

1
2 3 4 5 6