Questions tagged [bash]

BASH is the GNU Bourne Again SHell, the successor to the classic Unix Bourne sh (shell). It's the default shell for various GNU systems.

Filter by
Sorted by
Tagged with
2
votes
1answer
9 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; ...
5
votes
2answers
31 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. ...
1
vote
0answers
28 views

Creating a backup of a website directory inside the Web Application Root directory in *nix

In CentOS I have a Web Application Root on which I have a website directory. I would like to make an immediate backup of that website's directory by using the zip ...
7
votes
3answers
210 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 ...
2
votes
0answers
22 views

NRPE script for monitoring cpu usage

This script uses information from /proc/stat for counting current cpu usage. More precisely, it counts with these lines: ...
1
vote
1answer
30 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
33 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. ...
8
votes
2answers
55 views

Display git commit statistics in bash

I have scripts to display commit statistics and merge statistics of my repos, and they work. I wrote them for my personal usage, and because I was interested in finding trends in my git repos. This ...
5
votes
3answers
82 views

To print asterisks based on inputs

I have to print the number of stars that increases on each line from the minimum number until it reaches the maximum number, and then decreases until it goes back to the minimum number. After printing ...
3
votes
2answers
27 views

git Create Tree from Arbitrary Directory (works in bare repository)

I made a script for a project I'm working on to create a tree object from a filesystem directory, without any working tree operations (can be run in a bare repository). The tree can be inserted into (...
6
votes
1answer
45 views

Small app to show variables declared in a bash script

This code and updates are available on Github. I've written a small utility to dump the variables that are assigned in a bash script. Please note: This script depends on the shfmt and jq apps. I am ...
3
votes
1answer
28 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 ...
2
votes
1answer
48 views

Upgrade Firefox Quantum with logging and version check

This is the updated version of the script first posted here. Specifically, I first wanted to save the logs to a log file at "$HOME/.logs/ffupgrade.log", but I'm ...
8
votes
1answer
232 views

Upgrade Firefox Quantum from tarball

I wrote a little script to automate upgrading Firefox to a new version under Debian, since I don't want to install it from unstable and the snap version has ...
2
votes
0answers
30 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 ...
3
votes
0answers
20 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
45 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 ...
9
votes
1answer
112 views

Bash completion functions for pmount and pumount

I found a problem with Debian's Bash-completion for pmount and pumount, and intended to add a patch to the bug report - but I ...
3
votes
2answers
39 views

Script to create shell aliases

Can anybody find anything to pick apart in this script? ...
1
vote
1answer
39 views

Remap ls to honor .hidden files

I wrote this code in my .bashrc to remap ls to honor .hidden files. I'm pretty new to shell/bash scripting, so I feel like this is not the most performant way to handle this, and it has some ...
4
votes
2answers
46 views

Command to measure CPU time and RAM usage of process while making sure it does not go over certain ressource limitation

I found some old code of mine and am trying to see if it can be improved. The goal is to write a command that measures a process's CPU time and RAM peak usage and kills the process if it exceeds a ...
2
votes
1answer
29 views

Script to move images into year and month folder

This following code searches for jpg files of size larger than 500 KB. Its purpose is to move/cp files, depending on their EXIF data, into folders that correspond ...
2
votes
0answers
30 views

BASH script to obfuscate android/meterpreter payloads

I have written a little script that does a pretty good job of obfuscating android/meterpreter payloads. It will generate payloads or used supplied msf payloads while also injecting a custom icon. The ...
11
votes
2answers
509 views

Parallelized for loop in Bash

I am using a Bash script to execute a Python script multiple times. In order to speed up the execution, I would like to execute these (independent) processes in parallel. The code below does so: <...
3
votes
1answer
34 views

Syncing GitHub repositories local, remote and forks

It's a simple bash script but I'm hoping for feedback, advice and examples on how to improve the script and code. Can you guide me how to put more checks in the code and more if possible? This code: ...
7
votes
1answer
40 views

Bash script to encode images in base64 and generate a CSS file from them

These are the first lines of code I've ever written. I've been interested in the idea of learning to program for quite a while, but never really pulled the trigger, and now I've been playing around ...
1
vote
1answer
68 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 ...
2
votes
0answers
39 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 ...
9
votes
2answers
796 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
1answer
46 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 ...
2
votes
2answers
53 views

Looking to shorten method of parsing arguments in BASH

I have here a working method of parsing input arguments however it seems redundant. I would like to shorten this code so it doesn't appear so repetitive. ...
5
votes
2answers
54 views

Smart way to shorten the current working directory in pure Bash

I'm trying to create a shell prompt that displays the $PWD in a "smart" way. I want to display the top two directories rather than the full path. If ...
2
votes
1answer
26 views

shell library for Debian package releases

This is a bash library intended to be used in a CI/CD pipeline to make finding the next release number for a Debian package semi-automatic. I figured out how to ...
4
votes
1answer
75 views

Bash script to setup new Debian installs - follow-up

I have this bash script I've been working on and I have updated it. I was hoping for some advice and/or input on the code. This script is run directly after a fresh install of ...
4
votes
1answer
66 views

Removing duplicate field entries from sorted csv data

Given the following input (cat i.txt), I want to remove duplicate field entries in each of the first three columns and none of the others. ...
4
votes
1answer
62 views

Shell script to calculate the total space consumed by a user by file-size

I'm working with a small bash code which is working fine but i'm just looking if there is better way to formulate this, In this code i'm looking for the Files between year 2002 and 2018 on the 7th ...
2
votes
1answer
102 views

Create Apache2 virtualhost, Mysql db & user. CLI tool and GUI on top of it

Review for optimization, code standards, missed validation. What's in this version: Rewritten, instead of large complex script - few tools with each own task. Solid CLI tool and GUI script on top of ...
5
votes
1answer
87 views

Pure bash program for auto-filling a template file (Part 2)

This is my rewrite of the program posted here, based on janos's comments. I also added the ability to read from stdin. I've also included a test script. I wanted something lightweight I could ...
3
votes
1answer
53 views

Pure bash program for auto-filling a template file with ENV variables

Goal of Program Consider a template file template.txt with double brace variables, intended to be replaced by values: ...
5
votes
1answer
73 views

Batch upload users to nextcloud on docker with bash csv

I have this bash script that adds users to NextCloud from a csv file. It expects to be run from the same directory as the docker-compose.yml file. I'm pretty new to bash scripting and I'm wondering ...
1
vote
1answer
21 views

Revised media ingest script

link to original question: Simple media ingest script As per answers I have refactored my code and would like to get feedback on the current structure. The purpose of this tool is to allow someone ...
3
votes
1answer
27 views

Local backup bash

The following code copy a complete folder (that has 3 folders inside), then check if errors are generated and send email if there's errors, the it proceeds to create 3 different tar files and finally ...
4
votes
2answers
43 views

Simple media ingest script

Trying to script a simple command line tool for ingesting media to a target location following a structured naming convention. It's functional in its current state but I'd like to know if there are ...
6
votes
2answers
1k views

Backup with Hanoi Strategy

I want your suggestions about this shell script. I use it to backup some configurations on my home media server. What improvements would you do? Keep in mind, I want to optimize space and speed and ...
4
votes
2answers
55 views

Append a note to one of three files based on user choice

The user selects one of the three categories then makes a note on that selection. Then the note is appended and saved to the appropriate list. It took me four hours to write this. I'm trying to learn ...
9
votes
5answers
173 views

Disallow `rm` to remove `*`

Note: If you googled this by the title of this question, don't use this script unless you know what it is supposed to do. This is a script in bash 3+ that I have ...
2
votes
2answers
71 views

Create Apache virtualhost, MySQL db and user, install option - desktop shortcut for GUI version

Review for optimization, code standards, missed validation and dependency checks. Review version 3. What's new: apply previous code review input arguments and validation MySQL management (optional) ...
1
vote
1answer
43 views

bash script - Create virtualhost on development server (ver 2)

Review compatibility, readability, good code standards, security. This is for development server, where webmaster uses GUI fo IDE and fine way to create quickly apache2 virtualhost using GUI but ...
2
votes
1answer
91 views

Bash on Synology - Delete recycle bin entries over X days old

Synology NASs have a Task Scheduler that allows you to schedule deletion of files over X days old from recycle bins. This feature isn't working for me–running the task results in no files being ...