Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
0answers
20 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
51 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 ...
3
votes
0answers
44 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
96 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
77 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 ...
4
votes
1answer
42 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
44 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 ...
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 ...
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 ...
4
votes
2answers
35 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 ...
8
votes
5answers
150 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
69 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) ...
2
votes
1answer
36 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 ...
1
vote
1answer
42 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 ...
5
votes
1answer
57 views

Simple bash script creates apache2 virtualhost config for subdomain

Simple bash script to create apache2 virtualhost for localhost. Can be used for public subdomains on developer server with changes - "replace .localhost". Tested on Ubuntu, but should work where ...
0
votes
1answer
23 views

Refactoring with many duplicates using Bash [closed]

I have a curl based working bash script, but I have many duplicates on the "CURL" body. How do I improve it efficiently to eliminate duplications? ...
8
votes
2answers
531 views

Bash script to truncate subject line of incoming email

I'm going to put this script into production in a mail server /etc/aliases file: we have a system that receives email but the subject line must be limited to a certain size. The proposed usage in the ...
1
vote
1answer
20 views

Install a Python package based on active_gpu or version [closed]

I have the following code, is there a way to optimize it/reduce the code? ...
0
votes
2answers
60 views

Bash Script for file auditing, push information to server and be able to view in a web page

Edit: The goal of this Question was only seeking code review and guidance in learning or tips for improvement. I apologize if that was not clear or aligned properly with the goals of this forum. ...
2
votes
2answers
40 views

Bash - Passing arguments with “$@” to either 'sudo su' or 'sh'

I have a server where shell commands to the supervisor-service must be executed by the specific user lx. I have written a bash function that does exactly that. <...
3
votes
2answers
51 views

Creating remote directories in a bash script via ssh (with error trapping)

I'd like to create directories on a remote VM, but only if they do not exist. What's more, if creating the directory results in an error (exit status != 0) I'd like the script to exit as well, or at ...
1
vote
1answer
37 views

Bash function to produce variants of images at 2X and 3X resolutions

I use ImageMagick to crop image, encapsulate the related code to functions. Here is the code: ...
3
votes
1answer
16 views

Tagging the directories and switching between them by tags - follow-up (Part 2/2: business logic)

This is the bash script responsible for changing the directories via textual tags. (See here the entire project.) dt_script ...
1
vote
1answer
27 views

Mac Bash: how to combine the open and str subtract to one line code? [closed]

new to bash , I use the following code to open the super folder with a file path. function openUp(){ cd $(echo $1 | sed 's@\(.*\)/.*@\1@' ); open .. } like ...
1
vote
2answers
27 views

Bash script to find included files in C code

I've got the following shell script (let say get_includes.sh): ...
3
votes
1answer
46 views

Bash script to backup a LAMP server

I wrote a bash script for backing up my LAMP server. To be honest that's my first experience in bash so I want to ask you for help in its improvement. ...
0
votes
2answers
33 views

“command preprocessing” with bash - string parsing and handling pipes [closed]

The following is a bash script named wrapper.sh: ...
4
votes
2answers
61 views

Upload a directory, in parallel, to an artifact repository

This code uploads an entire directory and allows for its reparenting on a remote server (an artifact repository). Three concerns: Copying the files locally takes a lot of space. Ideally, I could use ...
4
votes
1answer
63 views

Select second field in text table with shell script

I am writing a bash script to mount openshift service accounts into kubernetes objects. The right secret to use is highlighted in this text: $ oc describe sa sa-...
3
votes
2answers
87 views

Removing commented dead code without removing the legitimate comments

This question is the real question asked on StackOverflow. I'm here to review my answer and see how can I optimize it. Here is the answer text: This is a basic approach, but it proposes a proof of ...
4
votes
1answer
44 views

Bash function to find contents of a file with a certain extension

I have to read a lot of code and search through many code bases. I frequently find myself using something like grep -r --include=.C "test string" . to find files ...
3
votes
2answers
69 views

bash wrapper around 'git commit' to automatically bump (Python) package CalVer and create matching CalVer tag on new commit

I'm doing a lot of Python development lately for various (small-)data analysis pipelines at work. I've been wrestling with how to robustly and ~automatically version the code at a fine-grained level, ...
4
votes
2answers
58 views

Serial copying from disk images to folder in Bash

This is a Bash script that copies files stored inside disk images to a directory, using a defined structure provided via a JSON file. I've included the external programs it requires and the test I ...
3
votes
2answers
62 views

Code to get the IP address and format it to run in nmap

For scanning my subnet using my IP address, I need to run the following command nmap -sn 192.168.100.* I want to extend this functionality such that I don't have ...
3
votes
1answer
99 views

BASH Script to Configure Monitors on Linux via xRandR

My main computer is a laptop which I run i3wm atop Arch Linux. As such, my monitor situation sometimes changes, so I wanted to code a script to configure my monitors based on which ones are connected ...
1
vote
2answers
26 views

Bad performance bash, changing display brightness

I have a script that changes the display brightness using xrandr. It is my first bash script. I mainly had a lot of trouble with dealing with the floating point ...
2
votes
1answer
52 views

Simple bash argument parser

In a bash script, I need to parse arguments that have the following form: The main arguments can be thought of as being a single argument, but I do not want to force users to quote the entire thing, ...
4
votes
1answer
39 views

Iterate over files and convert with a new name / directory

I'm pretty new to bash scripting. I want a script that I can run in a directory that contains .md files, runs pandoc on them, and delivers the output to a sibling ...
2
votes
1answer
67 views

Partial Maven clean install after Git pull

I had searched for a solution to mvn clean install on my changed projects after a git pull. I even asked a question over at SO ...
1
vote
1answer
313 views

SSMTP configuration in Ubuntu 18.04 with Bash in my own system (one user)

This is how I configure the utility SSMTP that allows me to send mail via smtp protocol through a Google-Gmail proxy instead I'll have to manually configure an "...
4
votes
1answer
43 views

Script to clean up old files that should only run one instance

I'm writing a bash script for deleting old files on a Linux server. Here are some relevant facts about this script: As currently written, it does work as expected. However, it's entirely possible ...
1
vote
0answers
204 views

Elastic Beanstalk configuration using ebextensions container_commands combining leader_only and test

For our Django app running on AWS Elastic Beanstalk, we use a web-server/worker setup. The same code is deployed to the web-server and worker environments, and environment-specific configuration is ...
3
votes
1answer
51 views

Bash program that sets up and configures the environment for new Debian installs

Here is my second version of a bash program I'm writing, as per @hjpotter92 I've updated and cleaned it since last: This script is run directly after a fresh install of Debian, to do: sets up ...
4
votes
2answers
49 views

CGI for htpasswd registration

I decided to go with a very simple CGI user registration program to pair with Apache's mod_auth_form wrapper around a private site. It was only just after I ...
3
votes
2answers
43 views

Check that file is fully downloaded by FTP

I have a task in which I want to handle error occurred in FTP downloading, For which I used the wget command to download a file via FTP and once the download is ...
2
votes
2answers
123 views

Bash script to change network interface parameters/configuration and start virtual machines

On my Arch Linux system I have created a script that should do the following on system startup: detect all network interfaces check if physical interfaces are up check if bridge interfaces are up ...
2
votes
1answer
29 views

Ubuntu kernel update and removal automation script

This is my first bigger than a few lines bash script. It automates kernel updating and removing on Ubuntu through ukuu (Ubuntu kernel update utility). I'm not yet ...