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
23 views

Database playground

This is my very first interaction with databases. The goal is to setup a safe playground on an Arch box to create tables and make queries. I want to learn the basics without risking ...
2
votes
0answers
18 views

Optimizing script to move files

I wrote a bash script to move certain files within a group of directories with filenames that match certain conditions to another group of directories, but it is very cluttered. If possible, I want ...
1
vote
1answer
37 views

Extracting emails from log files

I have huge number of text files, each several hundred MB in size. Unfortunately, they are not all fully standardized in any one format. Plus there is a lot of legacy in here, and a lot of junk and ...
2
votes
0answers
26 views

Bash script to mirror XWindow to remote SSH host

The source code within this question aims to provide a short-cut for mirroring a local XWindow (or session) to a remote host via SSH port forwarding, such as: ...
4
votes
1answer
53 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 ...
1
vote
1answer
54 views

Bash script backup program

I've started bash scripting recently and currently I'm working on a program that simplifies backuping using rsync . I'd appreciate any feedback on what I've done ...
1
vote
0answers
20 views

a beginner's approach & confusion bash script

I've started learning bash today, but I knew basics of javascript. It would be very nice if anyone can point me at least a few advices on the code. Because there are so many details in bash, I hope ...
1
vote
0answers
23 views

Randomly generating invoice IDs

As more fully detailed in my question here, I'm in the process of starting a small, local business and wanted to avoid showing sequential invoice IDs to clients, and instead generate completely random ...
1
vote
0answers
26 views

Simplified Bash getopts flow

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

Parse and clean large log files

I have the code below, which works successfully, and is used to parse, clean log files (very large in size) and output into smaller sized files. Output filename is the first 2 characters of each line. ...
-1
votes
1answer
24 views

Split large log file like a dictionary [closed]

I have a large log file in the following format. Do note that this is already sorted alphabetically. I wish to split it into smaller pieces, and with file names reflecting the content of the file (...
1
vote
0answers
12 views

A simple git_status to prompt

The following bash script was made to retrieve some local repository information in order to be used to display a condensed git status in terminal PS1 prompt. It ...
2
votes
2answers
617 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
28 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
115 views

Installing GNOME extension via CLI

Intending to reuse the installation process of a GNOME extension, I wrote the following script: ...
2
votes
1answer
34 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
41 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
55 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
40 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
52 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
19 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
42 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 ...
3
votes
1answer
109 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
152 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
25 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
23 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
29 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 ...
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
48 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
0answers
41 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
93 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
21 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
95 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
940 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
170 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 ...

1
2 3 4 5
14