Skip to main content

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
5 votes
2 answers
65 views

Clean up and datestamp file names

I would like to ask for a review of the following Bash script which cleans up and datestamps file names, with an optional feature to rename the file. The main use case is renaming files downloaded ...
Thure Dührsen's user avatar
2 votes
2 answers
44 views

Check if program has been installed successfully at a given path

The path is provided as an argument by a Makefile within an install target. The script verifies if the specified path is already included in the system's ...
Harith's user avatar
  • 9,442
3 votes
1 answer
41 views

Generating a Benchmarking Report for a Program

Objective: The script should pass each file present in the data directory to the read_file executable, and print its result and ...
Harith's user avatar
  • 9,442
2 votes
1 answer
61 views

Text-based tic-tac-toe in bash (continued)

I wrote this two-player tic-tac-toe program in bash. To make a move, you enter a number between 1 and 9 which corresponds to the square: ...
sbottingota's user avatar
6 votes
1 answer
175 views

Text based tic-tac-toe in bash

I wrote this two player tic-tac-toe program in bash. To make a move you enter a number between 0 and 8 which corresponds to the square: 0|1|2 3|4|5 6|7|8 This is ...
sbottingota's user avatar
5 votes
2 answers
102 views

A shell function to copy files and directories, preserving directory structure

For a script, I came up with a shell function that might be generally useful. Before I add it to the code base, I’d like to hear someone’s opinion on this. I don’t write shell scripts often and had to ...
Bolpat's user avatar
  • 233
0 votes
3 answers
84 views

Bash script to read csv, manipulate data, write csv

This is pretty horrible code, but it works. I don't code in bash 😭, usually code in Python. This is a learning exercise for me, so that's why I'm using bash + that's why I don't use libraries. I ...
M3RS's user avatar
  • 373
4 votes
1 answer
49 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
1 vote
0 answers
49 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
290 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
64 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
49 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
  • 9,442
1 vote
0 answers
30 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
75 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
50 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
199 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
39 views

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

...
xwj's user avatar
  • 9
3 votes
1 answer
123 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 ...
Loki Astari's user avatar
  • 95.4k
1 vote
1 answer
84 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
73 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
65 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
112 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
38 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
76 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
144 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
85 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
154 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
  • 77.3k
4 votes
0 answers
130 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,099
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
356 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
51 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
151 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
4 votes
2 answers
136 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
59 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
56 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
2 votes
1 answer
28 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
  • 265
4 votes
1 answer
154 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
84 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
377 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
  • 313
1 vote
1 answer
67 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
55 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
53 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
136 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
  • 537
6 votes
2 answers
883 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

1
2 3 4 5
17