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.
808
questions
3
votes
1
answer
96
views
C++ Mock Library: Part 2
Parts
C++ Mock Library: Part 1
C++ Mock Library: Part 2
C++ Mock Library: Part 3
C++ Mock Library: Part 4
C++ Mock Library: Part 5
C++ Mock Library: Part 6
Removing redundant MOCK_SYS usage
After ...
1
vote
1
answer
28
views
VSCode-Portable Updater (MSYS2)
VSCode's portable mode doesn't support auto-updates, unlike its normal installer-based versions. I happen to use MSYS2's UCRT64 environment which makes the Linux tools I like play nice with the ...
5
votes
1
answer
46
views
Bash/perl function to search `lsblk` for drives whose partitions all match a filter
The following function searches for disks whose partitions all have an attribute that match a filter when listed with lsblk. Comments are in TomDoc format.
...
3
votes
1
answer
44
views
Bash/perl function for filtering and formatting `/etc/fstab`
The following function filters and formats /etc/fstab for future use. Comments are in TomDoc format.
...
5
votes
1
answer
91
views
Script to loop through a list of YouTube channels, and output metadata to a Markdown file
Overview
I have created a bash script (triggered via GitHub Actions) that does the following:
Parse a list of YouTube channel IDs and nicknames.
Fetch their metadata via YouTube's Channel API.
Build ...
1
vote
1
answer
31
views
Find missing files from subdirectories given the file names have sequential number
I have a directory structure like bellow.
...
3
votes
1
answer
63
views
Follow-up Q: Protein databank file chain, segment and residue number modifier
I asked a question yesterday (Protein databank file chain, segment and residue number modifier) and received a very informative answer by J_H whose feedback I have taken onboard. Some of the feedback ...
4
votes
1
answer
101
views
Protein databank file chain, segment and residue number modifier
My first non-trivial bash script after fully moving to Linux Mint last week is attached (modify_cccp_bundles.in). The script ...
2
votes
2
answers
79
views
Generate a checksum for this input
I am inputting a file of uniq -c | sort -nr and I need to
take the string from the file,
generate a unique id of the string and then
Output a pipe separated value ...
3
votes
1
answer
72
views
Replace values in key=value configuration files
I have a handful of files containing simple configuration in which I need to modify values. There are some useful constraints that simplify my implementation:
The file consists of single lines of ...
3
votes
0
answers
109
views
Processing large blocklists with GNU Parallel
This is an ongoing project that has undergone a major update to speed up list processing. Here is the homepage for anyone interested!
It processes lists defined in ...
0
votes
3
answers
61
views
Bash Script Conditionals for Commands and Testing
I know this is basic, being a Bash beginner, I like to learn the level of checking and testing when calling commands like; cp, mkdir, wget,... in a Bash function, and returning a result for the ...
1
vote
2
answers
121
views
Display free disk space
With Kubuntu 22.04 ...
Questions :
What is a better way than using 2 cases?
The 1st case, script Line 48 "case $x in"
lets user choose to clear screen or not clear.
The 2nd case, script ...
7
votes
1
answer
277
views
pure Bash way to trim
How can I improve this? I added the while read loop to handle preceding newlines.
...
3
votes
1
answer
41
views
Running multiple concurrent processes in a bash script, such that if one dies it takes the other ones down with it
This is my solution using job control.
Whenever a job dies, it kills the parent script
When the parent script dies, it kill the whole process group, including all jobs
I would hope that there's ...
1
vote
0
answers
37
views
Simulating Git in Bash for academic purposes
The idea is to have a minimal script that demonstrate how Git works. I would like to be able to build objects, trees, blobs, commits and demonstrate that a Git repository could be created using bash ...
2
votes
1
answer
109
views
Bash script that installs Arch Linux
I wrote a bash script that installs Arch Linux. I wanted to simplify the installation of the Arch Linux system by automating things like setting locale, hostname, networking, etc. This is my second ...
3
votes
2
answers
126
views
Processing a very long single line of comma-separated (?) floating point numbers
I have a sample svg file from the graphics program Inkscape. My objective is to collect every third pair from a very long line of floating point numbers. That seems simple enough. The larger objective ...
2
votes
0
answers
55
views
a C/Python X server interface extension package
The project is named winlin; it's a portmanteau of the words window and Linux.
I'm working on a CPython extension to interact with the X server and manipulate windows. I don't have a ton of ...
1
vote
1
answer
39
views
Getting Specific Value from Dmidecode Output with Bash Script
Below is a section from the dmidecode output. There is a part of this section that I want to break down. I want to get the 4 bytes after pattern 01 85 30. And I want to change the byte order. Then I ...
1
vote
1
answer
22
views
Performing analytics on access.log with Bash
Before I learned that GoAccess was a thing, I wanted an analytics solution that I could use locally on my web server. My solution was to write a bash script that would give me some basic info on how ...
3
votes
1
answer
92
views
Creating ZFS-based rootfs for installing Linux in Bash
I've written a bash script that creates a root filesystem on ZFS for installing Debian or Arch. The purpose of this script is to make it easier installing e.g. Arch without the need to make a ZFS pool ...
1
vote
2
answers
66
views
Shell script to download, compile and run Analog Clock in AEC
As some of you know, I have made a programming language, called AEC, and written two compilers for it, one targetting x86 and other targetting WebAssembly. Recently, I have tried to write two shell ...
8
votes
3
answers
375
views
Print full path to last modified file in a given location
Background
I've provided two simple functions that I use to print a full path to the last modified file within a directory. I don't code in bash frequently so I'm looking for a generic feedback on ...
1
vote
1
answer
49
views
Changing file encoding, removing mid-line LF, and converting DOS CR-LF to Unix LF
We have several thousand large (10M<lines) text files produced by a windows machine.
We need to change the file encoding of these files from cp1252 to ...
1
vote
1
answer
45
views
Backup algorithm in Bash using dry-run
This is my algorithm to backup data on Windows using Bash scripting language.
I'm looking forward to any innovations, and better solutions. My task was to create a simple backup algorithm using dry-...
2
votes
2
answers
45
views
Archive, compress, remove old archive file then remove source file if below set size
I'm working on a script that will archive, compress, clear old archive files, then remove the source file if it is below a set size. The output when I tested it worked, but I just wanted a second ...
4
votes
1
answer
86
views
fzf function and key binding for searching through environment bash variables
After inspecting fzf/shell/key-bindings.bash I came up with the following, to be put in my ~/.bashrc:
...
6
votes
2
answers
243
views
Extract data from api using shell scripting
So we have many vlans at work, often it is nice to see which ip ranges are associated with said vlan. We have a well developed api for displaying information about our network and thus I wrote a small ...
4
votes
3
answers
235
views
A shell script to get the current battery status
Is this code well written? I'm not doing much, just rendering my battery status for my status bar but the code seems pretty long. I am new to Bash and Linux, so I thought this code could be improved ...
3
votes
1
answer
58
views
PDFcomp: A PDF comprimer easy script
I developed this script in dead time to be able to compress the PDFs that they send me to university and also to be able to send scans to the various institutions that require formats that do not ...
1
vote
1
answer
50
views
Bash script to count word occurrences in file.txt version 2
This is version 2.
As time allotted some improvements from version 1 suggestions.
Question 1
In this script for Kubuntu 22.04.1,
how to set the Terminal scroll-back ...
3
votes
2
answers
63
views
Bash script to count word occurrences in file.txt
Bash script to count word occurrences in file.txt
How can this script be made more proper or more elegant?
Example output:
...
3
votes
1
answer
35
views
Split Text to Columns and move all data to the next column
Objective
I'd like to confirm if there is a more efficient approach for the working script below, which splits column data in my tsv files.
I suspect this can be achieved with awk or maybe sed but my ...
3
votes
1
answer
239
views
Find proceses listening on the network outside of default package manager v2
So this is a follow up questions to Find proceses listening on the network outside of default package manager
I managed to make it a little faster thanks to using ...
4
votes
2
answers
355
views
Find proceses listening on the network outside of default package manager
I have been tinkering with a script that should list things that are listening on the network, but are not part of the base packaging manager. Currently I have only done support for fedora and debian ...
5
votes
1
answer
499
views
Bash script simple countdown timer with dotted output
My goal is to have a timer function that operates from the bash linux command line. I am looking for review and feedback. Printing the expected number of characters (dots, dashes, or bars) is nice-...
9
votes
5
answers
2k
views
Weekly MySQL database backup
I haven't used Unix, etc. for 40 years, so I am a bit rusty. I need to back up the databases on my website(s) once a week and then retrieve them automatically from my development machine. So this is ...
3
votes
1
answer
301
views
Single instance of mpv while maintaining the coordinates of the previous window
The code I am using is:
...
2
votes
1
answer
96
views
Bash script to take user input to set AWS envrionment variable the first time and automatically in subsequent calls
Background
Our team has a utility called envmgr to set aws iam roles. The credentials are only good for 4 hours or so. As such, I have a number of scripts that call the command ...
3
votes
2
answers
290
views
Bash script using SSH to sum disk usage on NetApp
I have tried to come with below bash script which is at least working for me, i know its not perfect and that why i want some review and suggestion to make it more aligned with bash practices. I'm ...
3
votes
1
answer
404
views
Bash script to automatically test Artifactory access
Our team often has indeterminate access issues to our Aritfactory binaries. These issues can go missed because we may have our binaries locally cached and our projects builds may still succeed until ...
2
votes
1
answer
76
views
bash script to setup a digitalocean webserver (apache2, nginx, PHP7.4, fastcgi, SSL)
The following bash script is intended to be run on a freshly installed digitaloceans ubuntu 20.04 droplet by root in its home dir.
The purpose is to setup a ready to use webserver with SSL (certbot), ...
10
votes
4
answers
2k
views
Git Push Bash script
I created this bash script to make it easy to publish your files to a GitHub repository.
...
4
votes
1
answer
31
views
Download Ubuntu daily ISOs and make them into VMs for alpha and beta testing
I'm an Ubuntu contributor, and I finally got tired of the workflow for ISO testing I was using (zsync, gpg, sha256sum, create Gnome Boxes VM, install, delete VM). So I decided to make a Bash script to ...
3
votes
2
answers
538
views
Implementation of the "tee" utility program
How can I optimize the program? To make it more optimal? The program should be more optimal in terms of source code, compiled executable size, memory usage, speed, bugs etc. Please criticize the ...
3
votes
1
answer
50
views
Strive to ultimate bash argument parsing
I've tried my best to write argument parser to cover all my needs and I won't need to edit the body of parsing loop, never again(:)) to add/remove parsable flags. The resulting code seem to cover's my ...
3
votes
2
answers
92
views
Change query strings with a Bash script
The following script changes start and end dates of several queries saved as files in the folder /app/queries. It is used by executing the script and passing two ...
0
votes
1
answer
114
views
Execute several queries and save them to files in Bash
I wrote the following bash script to run queries saved in files and save them to csv files. The queries have to be run against a BigQuery database. I use the bq-cli ...
4
votes
1
answer
109
views
Implementing a data extraction pipeline with Bash
I wrote the following scripts to extract data from BigQuery and InfluxDB using the bigquery cli and the influx cli. The code works as expected. I included all files for completeness, but I'm primarily ...