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

tar-backup V1.01 - backup script for Linux (full and differential backups)

The backup script itself. Make it executable and place it somewhere in your path: ...
1
vote
3answers
81 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 ...
6
votes
1answer
74 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. ...
3
votes
0answers
30 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 ...
4
votes
2answers
74 views

Automatic CRL files converter

In my job we use our internal CA, which runs on a Windows server. When I want to use its CRL on a Linux machine I have to do these steps: download root CA and intermediate CAs covert them to x509 ...
3
votes
1answer
167 views

Extract numbers from the head of a string in BASH script

In my current BASH script project I am processing a string, which cannot have spaces. At one point I get to where it is possible to have a series of digits. The series can be of any length, including ...
3
votes
1answer
45 views

Batch rename files recursively, and number the directory index

When dealing with iOS app bundle, It is not convenient to get the file by its path, but loading it by its name. Need to batch rename images recursively, with Mac Bash. And to make the name unique, ...
3
votes
1answer
30 views

Batch rename files with Mac Bash,while the dir index should be recorded

I need to batch rename images with Mac Bash,while the directory index should be recorded. To rename files ,turn ...
0
votes
0answers
29 views

bash script at scale for kubernetes kubectl operations

I have my below prototyped script and it runs fine but I need to scale it out at large. So, wanted to get feedback if my script can be improved in terms of performance and if there are any non ...
2
votes
2answers
119 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 ...
7
votes
3answers
443 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 ...
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 ...
2
votes
0answers
82 views

Bash bitcoin blockchain explorer

I wrote a little bash script that displays the transaction info in json: ...
1
vote
1answer
32 views

Sed script to update a version number in an RPM SPECS file

I have a specs file: Name: program Version: 2.3.3 Release: 0 ... I want to update the version number every time it's built. I perform the ...
6
votes
1answer
82 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; ...
1
vote
2answers
61 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 ...
1
vote
1answer
49 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 ...
7
votes
3answers
246 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 ...
3
votes
2answers
39 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
78 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
123 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 ...
6
votes
1answer
56 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 ...
2
votes
1answer
54 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 ...
2
votes
0answers
35 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
29 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
52 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 ...
3
votes
2answers
54 views

Script to create shell aliases

Can anybody find anything to pick apart in this script? ...
5
votes
2answers
39 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. ...
3
votes
1answer
38 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 ...
3
votes
2answers
31 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 (...
2
votes
1answer
49 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 ...
1
vote
1answer
42 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
57 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
0answers
174 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
545 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
43 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
57 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 ...
2
votes
0answers
42 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
1answer
79 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
2answers
994 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: ...
2
votes
2answers
60 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. ...
3
votes
1answer
75 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
1answer
28 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 ...
5
votes
2answers
61 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 ...
4
votes
1answer
72 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
68 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 ...
4
votes
1answer
86 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 ...
2
votes
1answer
110 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
98 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 ...

1
2
3 4 5
14