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
1answer
55 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 ...
3
votes
1answer
89 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 ...
0
votes
1answer
21 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 ...
0
votes
1answer
47 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 ...
3
votes
1answer
24 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 ...
2
votes
1answer
37 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 ...
2
votes
1answer
36 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 ...
3
votes
1answer
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....
5
votes
1answer
46 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 ...
5
votes
2answers
235 views

c++ shell for linux

...
2
votes
1answer
21 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. ...
2
votes
2answers
46 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): ...
5
votes
1answer
60 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 ...
5
votes
1answer
237 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 ...
11
votes
2answers
2k views

Memoizing or caching Bash function results

Update: I've implemented several of the features suggested below and packaged the improved code into a dedicated project: bash-cache. I display a number of expensive operations in my Bash prompt (e.g....
1
vote
0answers
30 views

Project setup script

It's a pretty simple script really, i just want to know if there is a way to improve it. ...
2
votes
1answer
40 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. <...
1
vote
0answers
11 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 ...
0
votes
0answers
11 views

Run command with a modified PATH

When I test shell programs for portability, I often want to run them with different implementations of awk, sed, and several other tools. Of course I could make these shell programs flexible by ...
3
votes
0answers
50 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 ...
4
votes
2answers
209 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 ...
3
votes
1answer
35 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 ...
6
votes
2answers
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 ...
2
votes
0answers
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 ...
6
votes
1answer
113 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. ...
5
votes
1answer
264 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: ...
5
votes
1answer
110 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 ...
5
votes
1answer
52 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 ...
2
votes
3answers
85 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 ...
2
votes
2answers
124 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 ...
3
votes
0answers
32 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 ...
13
votes
5answers
3k views

Git delete all merged in local branches

I have written a shell script utility for deleting all merged local branches. ...
3
votes
2answers
878 views

Group and send all files to filetype folder

I have around ~2M of files in one folder, which I need to manage. So, I want to separate them in groups by their filetypes. Example: filenames ...
3
votes
1answer
29 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 ...
6
votes
1answer
91 views

All-core MediaWiki website upgrade script

I wrote the following Bash script to upgrade All-core MediaWiki websites (no added extensions/skins or images - besides logo image). I already tested the essence of this script and it worked for me; ...
3
votes
1answer
574 views

Powershell script to stop and start services on demand

The purpose of below code is to stop/start a couple of windows services if they are running/not running, this will be called from a windows command line. The services could be either on a windows ...
2
votes
3answers
49 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 ...
7
votes
3answers
480 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 ...
3
votes
1answer
111 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. ...
7
votes
2answers
133 views

Bash script to send notifications when low on ram

Backstory Recently, we've changed the PCs at my workplace to un Linux Mint. It works amazing, is blazing fast and the adjustment time was very short. However, I noticed my PC would freeze completely,...
3
votes
1answer
39 views

Deployment Automatization for docker builds, kubernetes deploys and secret injection

I've written a small script that automates the tasks I previously did manually for deploying onto our kubernetes clusters and I am quite happy with the results I have, but I do think that what my ...
5
votes
2answers
41 views

Bookmarking directories

When working on a large codebase, I often need to switch between deeply nested directories quickly. To make my life easier, I came up with a bookmarking script. ...
2
votes
1answer
45 views

Script to Backup Data to Remote Location. The data to backup depends on the day of the week

I have a script that I wrote, and I'm sure that there is a better way to do it, but can't for the life of me figure it out. Here is the problem statement: I need to backup data to a remote location, ...
7
votes
3answers
263 views

NRPE script for monitoring load average

This script converts a server load value into percentage, compares it with non desired state ($warning and $critical) and returns all information in NRPE (Nagios Remote Plugin Executor) friendly ...
1
vote
1answer
52 views

NRPE script for monitoring memory usage

This script based on previous NRPE script for monitoring load average. Same purpouse - get NRPE friendly output with minimal usage of non built in commands. In this case wasn't need to count with ...
3
votes
2answers
48 views

a wrapper for bbcp

I am writing a small bash wrapper for bbcp. This is a fast network file transfer utility. bbcp requires the destination folder to be the last argument. ...
2
votes
1answer
52 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, ...
2
votes
0answers
38 views

Bulk File Rename; Improved Safety and Performance

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 ...
4
votes
0answers
34 views

Rename files by editing their names in an editor

Inspired by the a recent question to rename files by editing the list of names in an editor, I put together a similar script. Why: if you need to perform some complex renames that are not easy to ...
3
votes
1answer
57 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 ...

1
2 3 4 5 6