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
1
vote
0answers
22 views

What is a better practice in bash scripts to test if string is empty: [[ -z ${value//[0-9]/“”} ]] or ! [[ ${value//[0-9]/“”} ]]?

I test in a bash script if a variable value contains digits only. There are two options, both give the valid results: ...
6
votes
1answer
91 views

Installing GNOME extension via CLI

Intending to reuse the installation process of a GNOME extension, I wrote the following script: ...
2
votes
1answer
30 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. <...
3
votes
1answer
40 views

Bash script to send certain data from AWC EC2 to CloudWatch

Here's a little bash script I wrote, which basically checks something on an Amazon EC2 instance and reports data to CloudWatch every 60 seconds. I'll run this inside a container. Everything works just ...
3
votes
1answer
53 views

Extract multiple attributes values in XML tags

I have a XML file (test.xml) that can be sum up as follow (I filtered it so it will be more readable): ...
1
vote
0answers
35 views

One of my first Bash scripts - checking for best practice and error handling

I have a Bash script that resides on Remote Server A and transfers files from Remote Server 1 to Remote Server 2. Remote Server 2 is a Dropbox folder so in this script, I call another script (that's ...
3
votes
1answer
72 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
0answers
43 views

realpath substitute with --relative-to and --relative-base support

In a bash 3 script for OSX machines, I needed the functional equivalent of the realpath command, complete with support for the ...
1
vote
0answers
18 views

Slow bash script for getting audio/video duration

I have created a bash script to generate a HTML file, which will have the duration of the audio/video files in the current folder. The script uses ffprobe to fetch ...
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 ...
3
votes
0answers
40 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 ...
10
votes
2answers
1k views

Calculating pi using bash

I've written a little program to calculate pi using the Nilakantha series: For this formula, take three and start alternating between adding and subtracting fractions with numerators of 4 and ...
1
vote
0answers
19 views

General-purpose getopts utility for Bash

I've always found the boilerplate needed to use getopts correctly fairly fiddly and verbose, and was motivated to try to abstract it away. I wanted to try ...
3
votes
1answer
108 views

cron daily and weekly scripts for a minimal Nginx server environment

I've created the following cron for daily and weekly scripts for a minimal Nginx server environment (as part of my larger script). The daily cronjob updates WordPress and brings back original ...
4
votes
0answers
150 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: ...
2
votes
0answers
24 views

Bash wrapper for connmanctl with autocompletion

So the idea came from the fact that connmanctl only completes filenames/directories when used non-interactively, whereas when used interactively (executing ...
4
votes
0answers
20 views

Listing my StackEchange communities user id

Extending this answer solution, I've wrote the following bash script to get the html of my StackExchange accounts page and parse it to a YAML file. The objective ...
3
votes
0answers
30 views

Merging multiple awk commands while retaining functionality

Turned in a project a few days ago, and I needed a way to filter and format values off a file. I decided to go for a bash script since it seemed like a good option, and I came up with the following: <...
3
votes
0answers
24 views

Using SSH.NET to interact with a Bash shell

I'm trying to interact with a bash shell on a router to automate some CLI commands using SSH.NET. I'm not sure if the approach I'm taking is the best one and would like to get some recommendations on ...
2
votes
1answer
51 views

Comparing two bash caches

I was working on making a cache in bash and I found this link - But this guy is attempting to generate new bash functions by introspecting their source and generating a new one as a cache. This seems ...
10
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....
9
votes
2answers
261 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
1answer
39 views

Parallel download of rpm packages

I use zypper to download and install for openSUSE Tumbleweed (much like everyone else of course). Unfortunately it downloads packages serially, and having about a thousand packages to update a week, ...
2
votes
0answers
13 views

bash script to delete files resurrected by Adobe InDesign bug

After a March update, Adobe Indesign will resurrect removed directories it was responsible for creating in the first place, but not any files except for one file called "AdobeFnt.lst". So where once ...
6
votes
5answers
258 views

Upgrade script for MediaWiki website with one external addon (wave 1)

I have a MediaWiki 1.33.0 website with only one external addon installed (external extension), which is ContactPage. I have created the following script with that logic: if there is an upgrade to ...
2
votes
1answer
41 views

Writing a better deploy script

This is a script I've written to deploy the Elastic Stack. Can you help me improve it? Especially the parts called out with *** markings. ...
4
votes
1answer
45 views

Finding missing void keywords in C source code

I'm writing a bash script to search C source files and find the lines where I missed the void keyword (unlike in C++, in C, empty parameter lists have to be indicated with the void keyword). I read ...
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 ...
2
votes
2answers
568 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 ...
2
votes
0answers
37 views

Vim swap file sweep and recovery

This is the draft contents of a function intended to be run after a system crash in order to quickly review all of the recent vim swap files. They will be loaded up into and displayed in a vim ...
3
votes
1answer
77 views

bash script to bulk decode files

I have written script that does the following. It uses cbl-log program to decode several log files in binary format. cbl-log ...
3
votes
1answer
47 views

A temporary directory that exists only during run time of user-specified code

For a research analysis, I'm writing a small bash script that serves as a frontend to Singularity. The reason is that I want to save in this script which options are needed for singularity. For ...
2
votes
0answers
71 views

Qutebrowser Searchengine Script

Qutebrowser uses search engines similar to DuckDuckGo's Bangs to facilitate searching. The config.py file for the browser contains a search engine Python dictionary....
0
votes
1answer
19 views

Clean up after shell script that is run via k8s pod on a gpu node for health check

Team, I have a working script but when we upgraded some drivers on the GPU system it’s starting to cause zombie process and system is lowing down as script runs periodically as a crib job. so I am ...
3
votes
1answer
75 views

Pandoc batch conversion

I wrote a simple bash script in order to batch convert Markdown files via pandoc and it is working for me. But I have the feeling the code is dirty. Could you help ...
6
votes
2answers
938 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 ...
4
votes
2answers
164 views

Bash code to install bootstrap in a Ruby on Rails repository

Wrote some code to install bootstrap (latest) in a newly created rails application. update: fixed a typo ...
6
votes
3answers
2k views

Fahrenheit / Celsius temperature converter

This is a simple bash script (hopefully with a little style as well) for converting temperatures from Fahrenheit to Celsius and vice versa. ...
3
votes
2answers
62 views

Bash script to calculate when I wake up

This script tries to determine the time when you woke up. Of course, it only applies if you turn your computer on not too long ago after getting out of bed. If not, it might still be useful as an ...
0
votes
2answers
39 views

Prime number finder in bash

I need to learn bash at some point in the near future, so I decided to start playing around with it. This is really the first actual script that I've written and would like feedback. This finds and ...
3
votes
1answer
41 views

ffmpeg batch script for video resizing - improved

I posted a question here ffmpeg batch script for video resizing but I forgot the issue of the rotation and the video files were scaled with wrong dimensions. Below is the improved version of the ...
1
vote
1answer
55 views

Prefix all lines on standard error

Is this the best way to prefix all lines written by a Bash script to standard error? ...
5
votes
1answer
59 views

ffmpeg batch script for video resizing

I have a few hundred mp4 files (thanks android =/) that I need to convert. I only want to convert videos that are too large (>= 1080p) and I do want to keep the exif Information so the timeline is not ...
7
votes
2answers
67 views

Fix last n commits to previous commit automatically

I often find myself doing rebase manually in an interactive form in a way as follows. Say I want to squash two last commit to third commit. First I execute: ...
5
votes
3answers
188 views

Implement bash auto completion in Python

I created a script supposed to use python to autocomplete Python commands. The full code is available here, however, I can give you an example. For instance, let's consider: ...
6
votes
3answers
178 views

Count unique IP address in a date range from Apache log

I use the following command to get specific entries between certain dates from Apache log files. Then I filter out my own address and some bots, then I print out the IP, sort it, get the uniques, ...
4
votes
2answers
54 views

Get available port from specified range

I have a situation where we need to be able to run multiple instances of a Spring app with dynamically assigned ports defined at runtime. I need to be able to get an available port at runtime, create ...
2
votes
0answers
40 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 ...
2
votes
0answers
35 views

Python Script to look for DNS expiration [closed]

I just wrote a Python script that will take a list of urls and find which ones are about to expire. The program queries a database, gets the websites, sanitizes the list, then loops through the list ...
3
votes
2answers
405 views

hangman in bash

Rules 7 mistakes allowed. Hangman rules. Disclaimer I don't have a figure (drawing) of the hangman as this project took way longer than I thought I would take. It took like 9 hours during 3 weeks. ...

1
2 3 4 5
14