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

Tor Relay Startup Script for New Server

I created a shell script that I can pull and run to set up a new server to run a tor relay. Everything seems to work fine, but it install an obsolete version of tor (Tor 0.4.2.7). I have tried to ...
yololantern's user avatar
4 votes
1 answer
40 views

Blocking lock for dpkg

My deployment and configuration process entails multiple processes trying to invoke dpkg on my VM at the same time. While dpkg has a locking mechanism, it causes anyone not holding the lock who is ...
billp's user avatar
  • 43
0 votes
0 answers
36 views

Bash: executing a DAG of idempotent functions in topological order

Suppose that I want to subdivide a bash script into small idempotent functions, and I also want that those functions can depend on each other. For example, assume ...
Andrey Tyukin's user avatar
3 votes
1 answer
131 views

Bash scripts to convert json to associative arrays and then back to json

I'm a relative bash novice but have found it along with jq a great way to manipulate json scraped from various sources. I couldn't find any ready-made scripts to convert arbitrarily deep json to bash ...
joeblog's user avatar
  • 243
2 votes
0 answers
62 views

Advent of code 2023 day 9: Sequence extrapolation - in pure Bash

Part 1 Today's task involves extrapolating the next value in sequences, given in this format: 0 3 6 9 12 15 1 3 6 10 15 21 10 13 16 21 30 45 The task is to ...
janos's user avatar
  • 111k
3 votes
2 answers
44 views

Script to automate testing solutions

Here's a script I wrote to automate testing for multiple sample files across two solutions, aiming to streamline the process. The script, provided below, compares expected results with the output of ...
Harith's user avatar
  • 4,031
1 vote
0 answers
28 views

Advent of code 2023 day 8: Path finding in the desert - in pure Bash

Part 1 In today's task, a network of paths is defined like this: LLR AAA = (BBB, BBB) BBB = (AAA, ZZZ) ZZZ = (ZZZ, ZZZ) The first line ...
janos's user avatar
  • 111k
2 votes
0 answers
74 views

Advent of code 2023 day 7: Ranking Camel Cards hands - mostly in Bash

Part 1 Today's task is to rank hands in a Camel Cards game and compute the total score. In Camel Cards, you get a list of hands, and your goal is to order them based on the strength of each hand. A ...
janos's user avatar
  • 111k
2 votes
0 answers
41 views

Advent of code 2023 day 6: Count ways to win boat race - in pure Bash

Part 1 To paraphrase the puzzle, given the times and record distances of boat races like this: Time: 7 15 30 Distance: 9 40 200 That is, the first ...
janos's user avatar
  • 111k
3 votes
2 answers
40 views

Start script for several Spring Boot services

I have several Spring Boot and Angular applications/microservices that form together a whole application. As it is tedious to start them via the terminal, I've written the following script to perform ...
jmizv's user avatar
  • 135
5 votes
2 answers
1k views

Advent of code 2023 day 4: Count scratchcard points - mostly in Bash

Yesterday I thought was the last day of Advent Of Code 2023 that I do in Bash. I was wrong. I'm not even sure anymore that today will be the one. We'll just have to see tomorrow! Part 1 To paraphrase ...
janos's user avatar
  • 111k
1 vote
0 answers
102 views

Advent of code 2023 day 3: count engine part numbers - in pure Bash

Yes I'll keep doing this until I cannot be bothered to do it in Bash ;-) (Well today is probably the last one ;-)) Part 1 To paraphrase the puzzle, given some input ("engine schematic") like ...
janos's user avatar
  • 111k
6 votes
2 answers
1k views

Advent of code 2023 day 2: count possible qube games - in pure Bash

To paraphrase the puzzle, Santa takes a walk with an Elf, and they play a game involving a bag of colorful cubes. In each game, there is an unknown number of each colored cubes in the bag, and the Elf ...
janos's user avatar
  • 111k
5 votes
1 answer
193 views

Advent of code 2023 day 1: count trebuchet calibration numbers - mostly in Bash

It's that time of the year again! Although there's no more Winter Bash, we can still have all the Bash we want in winter ;-) Part 1 To paraphrase the description: For each line in the input: Find ...
janos's user avatar
  • 111k
-1 votes
1 answer
34 views

how to boost my script in fault tolerance ,performance and readability [closed]

...
xwj's user avatar
  • 9
3 votes
1 answer
114 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 ...
Martin York's user avatar
  • 94.6k
1 vote
1 answer
62 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 ...
404 Name Not Found's user avatar
5 votes
1 answer
65 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. ...
mikeLundquist's user avatar
3 votes
1 answer
62 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. ...
mikeLundquist's user avatar
5 votes
1 answer
103 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 ...
Jake Lee's user avatar
  • 153
1 vote
1 answer
34 views

Find missing files from subdirectories given the file names have sequential number

I have a directory structure like bellow. ...
Ahmad Ismail's user avatar
3 votes
1 answer
68 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 ...
JamesT's user avatar
  • 74
4 votes
1 answer
115 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 ...
JamesT's user avatar
  • 74
2 votes
2 answers
82 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 ...
Christian Bongiorno's user avatar
3 votes
1 answer
124 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 ...
Toby Speight's user avatar
  • 74.4k
3 votes
0 answers
119 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 ...
T145's user avatar
  • 3,087
0 votes
3 answers
66 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 ...
njc's user avatar
  • 1
1 vote
2 answers
130 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 ...
joseph22's user avatar
  • 159
7 votes
1 answer
340 views

pure Bash way to trim

How can I improve this? I added the while read loop to handle preceding newlines. ...
Andrew's user avatar
  • 75
3 votes
1 answer
46 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 ...
Carl Patenaude Poulin's user avatar
1 vote
0 answers
43 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 ...
nowox's user avatar
  • 1,099
2 votes
1 answer
136 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 ...
whiteman808's user avatar
3 votes
2 answers
133 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 ...
Bryan-StackExchange's user avatar
2 votes
0 answers
58 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 ...
gnarlyninja's user avatar
1 vote
1 answer
53 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 ...
embeddedstack's user avatar
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 ...
Bee H.'s user avatar
  • 123
4 votes
1 answer
130 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 ...
whiteman808's user avatar
1 vote
2 answers
71 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 ...
FlatAssembler's user avatar
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 ...
Konrad's user avatar
  • 323
1 vote
1 answer
57 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 ...
rxFt20's user avatar
  • 113
1 vote
1 answer
49 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-...
Marcinkiewicz's user avatar
2 votes
2 answers
49 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 ...
Brad Barnes's user avatar
4 votes
1 answer
109 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: ...
Enlico's user avatar
  • 547
6 votes
2 answers
583 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 ...
N3buchadnezzar's user avatar
4 votes
3 answers
333 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 ...
Diwas10's user avatar
  • 111
3 votes
1 answer
61 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 ...
NFVblog's user avatar
  • 61
1 vote
1 answer
51 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 ...
joseph22's user avatar
  • 159
3 votes
2 answers
71 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: ...
joseph22's user avatar
  • 159
3 votes
1 answer
38 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 ...
El_Birdo's user avatar
  • 131
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 ...
N3buchadnezzar's user avatar

1
2 3 4 5
17