Questions tagged [bash]

This tag is for questions about scripts written for the Bash command shell. For shell scripts with syntax or other errors, please check them at https://shellcheck.net before posting them here. Questions about the interactive use of Bash are more likely to be on-topic on Unix & Linux Stack Exchange or Super User than on Stack Overflow.

Filter by
Sorted by
Tagged with
0 votes
2 answers
31 views

Apply actions over selected elements in a list in bash

I have a bash script which has 4 elements, and I want to loop over the last 2. So I tried this: #!/usr/bin/env bash arg1=$1 arg2=$2 arg3=$3 arg4=$4 list_total=( "$3 $4" ) for my_element in &...
Alexis's user avatar
  • 2,126
0 votes
0 answers
20 views

RSA Public Key, Can't find command [closed]

I'm trying to connect my SSH key to google cloud and I'm getting an error that it can't find the command. I verified that I'm in the correct directory. Any help is greatly appreciated, Thank you! Your ...
sundaynightlive's user avatar
0 votes
0 answers
25 views

How do I make a sshpass scp bash script for password and not keys to be run as a cron?

I am trying to make a bash script to send a file. When running this in the terminal I get the error: line 4: warning: here-document at line 2 delimited by end-of-file (wanted `EOF Here is the script: #...
jasonharvey's user avatar
0 votes
1 answer
18 views

Set exit code of a prompt in a bash shell

I have a command that returns a number from 0 to n, and would like to catch that number and use as the exit code of the command itself. I was able to achieve it by doing this: sh -c $'exit $(command)' ...
Felipe Sierra's user avatar
0 votes
1 answer
18 views

Gitlab CI raising "unexpected end of file" error on nested multiline string

I have a switch case bash statement in my .gitlab-ci.yml file where I use cat <<EOF >> ... EOF statement, but it doesn't like and keeps failing. Here is the block raising error : build-...
nixmind's user avatar
  • 2,100
0 votes
0 answers
15 views

Install Bash on Windows Docker Container

I have a Windows Container running in Docker that I am using to run GitHub Actions. Bash is required for some of the actions that I use. How can I install bash into my Windows Docker Container? What I ...
Tyler's user avatar
  • 113
-3 votes
0 answers
22 views

Extract URL using bash with a function

I would like extract all URL in HTML source code of a page using bash/sh script. The URL to lookup is on specific format: https://subdomain.domain.com/keystring-randomstring.txt I would like keep ...
user518171's user avatar
-1 votes
0 answers
10 views

LDAP-Search command to get only users which are not expired according to shadowExpire [closed]

I have a problem... I want to provide a Nextcloud instance where users authenticate via LDAP. Currently every user that has ever been created in our LADP is listed and so the login would be possible. ...
lukas__bca's user avatar
0 votes
0 answers
13 views

crontab command return codes

When I run crontab -r, I get a return code equal to 1. It's actually working, it's deleting the crontab as it should. So I wonder if there is a summary of the return codes of crontab. I couldn't find ...
Alexis Dufrenoy's user avatar
-3 votes
0 answers
38 views

How to combine tables with several columns [closed]

I have two tables: cat 10 id335_678 cat 10 id998_345 dog 4 id223_112 id223_112 dog 1.65 5.4 2.15 20 id998_345 cat 2.1 10.15 5.43 3.22 id244_123 parrot 3.8 7.9 1.1 2.3 I need to combine these ...
Suzu's user avatar
  • 7
0 votes
0 answers
35 views

ECCP256 signature for JWT can't be validated

I'm trying to sign a JWT using the private key (ECCP256) embedded in my Yubikey5. Note that the ECCP384 is not working either. However, the signature verification is not working (i'm trying on jwt.io) ...
Luhko's user avatar
  • 17
-1 votes
1 answer
36 views

Why is the file name not displayed? (Bash Shell Script) [closed]

Here are the Code #!/bin/bash # Verzeichnis, das du überprüfen möchtest directory="/volume1/archiv/Test_Count" # Datum von gestern und heute im Format JJJJ-MM-TT yesterday=$(date -d "...
mStyx's user avatar
  • 1
0 votes
0 answers
42 views

Can I get bash to tab-complete a script in the current directory without using `./`? [closed]

Let's say I'm in a directory containing a script called demo.sh, and I type de⭾. Currently bash (at least Git's bash for windows) won't complete this into ./demo.sh like I want. There's a couple of ...
nyctef's user avatar
  • 515
-3 votes
0 answers
29 views

Git command is returning any value in makefile [closed]

In my Makefile, the Git command isn't returning any value, and I'm seeking assistance to troubleshoot the issue. I've confirmed that the Git command is correct and functions as expected outside the ...
Yash's user avatar
  • 1
-1 votes
1 answer
27 views

Expect spawn "no such file or directory" error

When I run expect I cannot spawn anything other than additional instances of expect. expect1.1> spawn bluetoothctl spawn bluetoothctl couldn't execute "bluetoothctl": no such file or ...
Fitrillian's user avatar
0 votes
0 answers
46 views

auto incrementing version number in yml file

I am working with a Gitlab Pipeline. The file being used for the pipeline is the .gitlab-ci.yml file. I am using the Semantic Versioning method in order to obtian the version numbers for changes in ...
Casey Harrils's user avatar
0 votes
1 answer
35 views

How to pass a local script that requires an argument to Kubernetes pod?

I've seen this post which was incredibly helpful, but I am stuck with my particular problem. Where my problem differs from that post is that the script I have locally requires an argument. The ...
ryanflynn001's user avatar
1 vote
1 answer
77 views

Trouble with sed expression using unicode range in new environment

I have the following sed range replacement expression in a bash clean script I wrote years ago that works (or at least never gave an error) in the old environment but fails (with an error) in the new ...
Streamline's user avatar
  • 2,072
0 votes
0 answers
25 views

Storybook on Vite not starting: storybook bash script trying to exec a Node.js script

Important: See "Update" below. I'm running Storybook 7.5.3 for Vue.js on Vite 4.5.0 with Node.js v21.1.0. When I try npm run storybook, I get the following error: [29648:1206/145822.304:...
squirrelwhisperer's user avatar
1 vote
2 answers
84 views

Rearranging column order depending on different delimiters

I wrote a Bash script that receives input file, output file, delimter and column names in order to allow user to enter desired column arrangement by column name and get that arrangement in the output ...
sasa.asa's user avatar
0 votes
1 answer
33 views

Bash-scripted progressbar mixed with tail [closed]

Searching for some bash function: progressbar (pipiline) with tail of some last stdout lines. For example, last docker version can white only 10 lines of output while building image, very usefull. ...
Core 2 Duo's user avatar
-1 votes
0 answers
32 views

Docker entrypoint cannot execute binary files, but can in bash shell

I am working with this dockerfile that has an entrypoint that starts up a ROS 2 python script. FROM --platform=linux/arm64/v8 ncannon511/ros2-jammy SHELL ["/bin/bash", "-c"] ENV ...
Eclipse999's user avatar
1 vote
1 answer
78 views

Edit folder and xml files at once with comma delimited csv using sed

I'm trying to write a Bash script to change an XML file name and contents within this XML file for over 500 different folders. A member of the community helped with the first iteration of this ...
Trevor McDaniel's user avatar
-1 votes
0 answers
44 views

Sudo-ed script seems to ignore sudo -u <user> line prefix

I have a script that needs to be executed as root (sudo), and I am attempting to insert a systemctl --user ... line in it. Unsurprisingly, this does not work ("Failed to connect to bus: No medium ...
Aqualung's user avatar
-2 votes
0 answers
34 views

Bash for loop does not continue past first iteration without providing an error?

I have a bash script which is supposed to merge bam files located in different directories into one file. Each bam file was generated from one sample across 4 lanes and therefore I would like to merge ...
harpers29's user avatar
-1 votes
1 answer
40 views

Why does cpio deny access when copying to a USB stick? [closed]

I want to make a copy of /home on my USB. To do this I am running this command: sudo find /home | cpio -o > /dev/sdb while Im logged as root user. I have previously made sure that /dev/sdb is the ...
cnd's user avatar
  • 33
1 vote
1 answer
60 views

Ubuntu Webhooks is not reading the correct RVM ruby installed

I'm trying to set up webhooks on my system to do some ruby stuff on my machine automatically via running a bash script. The problem is that the ruby used while running the script manually differs from ...
Hazem Hagrass's user avatar
1 vote
4 answers
130 views

Iterate over dates in given interval with format like 20231205203830

I need to iterate over dates in a given interval, where dates have format 20231205203830 (5 of December, 2023 20:38:30). I can't change the format. I tried formatting the date with the following ...
George's user avatar
  • 590
0 votes
0 answers
22 views

Bash execute script with set +x and set -x same time [closed]

I have a bash script that always has to have the set +x parameter at the beginning, when I want to debug it, I delete this set +x line and run sh -x my.sh from the terminal. If I run this script as sh ...
eagerdev's user avatar
1 vote
0 answers
27 views

Why does runnig gdb inside faltpak stops the faltpak process and why does my workaround fix it?

I have figured out a way to start gdb inside a flatpak in a single command (instead of three steps), but it involves doing something strange to work around a quirk or possibly bug in gdb or in flatpak....
Andrey Bienkowski's user avatar
0 votes
0 answers
15 views

Udev hook to backup USB content not working, but script working

I've included a rule script in /etc/udev/rules.d to automate backup my USB content in a folder when i plug it in. student@student-VirtualBox:/etc/udev/rules.d$ cat 80-local.rules SUBSYSTEM=="...
Samuel Edi's user avatar
-1 votes
1 answer
29 views

ansi escape codes interface/non-hardcoded mapping

bash has support for ansi escape codes. i would like to use fancy and pretty printing of some test in a script. since i didn't find any basic builtin\lib\tool\script that provide this functionality, ...
Mr.'s user avatar
  • 9,612
0 votes
1 answer
48 views

While running SQL commands through shell script, Column headers are getting trimmed [duplicate]

I'm writing a shell script to get data using multiple select queries one after another but in my result output, my column headers are getting trimmed after two characters. Result I'm getting(Column ...
arpittguptta's user avatar
0 votes
1 answer
36 views

bash long options weird behavior - just for curiosity

I have this bash script, which does something after getting parameters. What I´m curious about is why it also accepts "--env, --envi, ..." when I just specified "environment" as ...
Wurzelseppi's user avatar
0 votes
3 answers
57 views

replace a specific text in all files with a text from its own file name in linux

Good Day! I have files in Ubuntu like: ZAF_MM_CYCLE_K051.XLS ZAF_MM_CYCLE_K052.XLS ZAF_MM_CYCLE_K053.XLS which are copy of a file "ZAF_MM_CYCLE_K036", the code of file is K036 File ...
Jonibek's user avatar
  • 98
0 votes
3 answers
69 views

remove duplicate lines keep one before

i want remove duplicate lines contains "from unit" keep one before like this input file: within unit 1 9. BD ( 2) C 3 - C 4 /***. BD*( 2) C 3 - C 4 14.88 ...
Adda Abdelghani's user avatar
0 votes
1 answer
56 views

how to restart consumer process using producer process in pipeline

I have this exactly: set -eo pipefail; while true; do echo '(re)starting server...' ( while read line; do if test "$line" == 'rs'; then echo 'restarting...' > /dev/...
Alexander Mills's user avatar
0 votes
1 answer
45 views

SLURM: Run Same Parallel Script on Multiple Files

What I'm trying to do is to run the same python script on thousands of input csv files. The python script is a single-process script that takes as input a single file and creates an output file with ...
camilo's user avatar
  • 3
0 votes
0 answers
28 views

How to pass complex arguments to msbuild in bash?

If I run this in Powershell it works: dotnet test /p:CollectCoverage="true" /p:CoverletOutputFormat="lcov" /p:Exclude="[*]System.Text.RegularExpressions.Generated.*" ...
Daniel Robinson's user avatar
-1 votes
0 answers
25 views

running GNU-bash scripts utilizing sed with (hopefully) a REGEX search [duplicate]

I'm struggling to get sed to accept/recognize my REGEX I'm processing data (a folder name, sent via a right click in Thunar) Creating a new folder (lhs of name), then renaming the old folder (to be ...
user22922196's user avatar
0 votes
0 answers
31 views

Trying to mass edit folder names with bash script - getting weird result [duplicate]

I'm trying to use CVS comma delimited replacement for a bunch of folder names on an Ubuntu using bash. I'm running the following: dir='/home/company/customer' while IFS=, read -r oldStr newStr; do ...
Trevor McDaniel's user avatar
1 vote
2 answers
71 views

How do compound-list conditionals operate in bash?

I am trying to understand compound lists in the bash environment and what the boolean return value is at the end of the list, but I have not found a complete answer. The definition of compound lists ...
Andrew's user avatar
  • 13
2 votes
2 answers
64 views

Scanimage can't get argument from variable

I'm trying to make a script for scanning and passing parameters using variables, but when I select a source it gives scanimage: setting of option --source failed (Invalid argument) Here is a script ...
Ilyasha's user avatar
  • 43
-1 votes
1 answer
60 views

SED command - Replace a key and value pair in JSON file - key name is similar to all Array objects [duplicate]

Goal to replace - "text": "V01_08_17", with "text": "Customized String", in below json file with sed File.json as mentioned above { "type": "...
Ram PG's user avatar
  • 1
-2 votes
1 answer
50 views

find timestamp in remote server (ssh) specific pattern filename [closed]

I need to create a script that should get the newest file based on a filename pattern from server A on server B. The command I run on server B is like this (server A is 103.11.34.111): ssh [email protected]....
Tiara's user avatar
  • 47
0 votes
1 answer
35 views

Bash - Iterate over map from k8s secrets call

I am requesting the details of a k8s secret: kubectl get secret mySecret -o jsonpath='{.data}' The answer of the call gives me the following map: 'map[first_password:ZXhhbXBsZQ0K second_password:...
Marvin Core's user avatar
-1 votes
0 answers
38 views

Cron job scheduling issue [closed]

I am facing the below error when I am running the script from crontab When I execute this ./test3.sh it works fine crontb command is */1 * * * * root ./test3.sh Here I am reading domain names from a ...
deepak PATRA's user avatar
0 votes
2 answers
68 views

Break variable to dynamic variables

The script accepts input as binary of various character length. For example input can be 00011010 or 001101001101101110111011 (up to 9 sets of 8bits) I have managed to split them per 8 bit. ...
texonec238's user avatar
0 votes
2 answers
67 views

Remove Curl and libcurl or Update it to latest version (>=8.0) in Docker in Nginx base image

I have a base image called docker-base which has a Dockerfile as shown below: FROM nginx:latest # Create app directory WORKDIR /var/www/app RUN rm /etc/nginx/conf.d/default.conf # Install app ...
merilstack's user avatar
-2 votes
0 answers
50 views

/usr/bin/bash: 5: find:: not found [closed]

torbrowser-launcher Tor Browser Launcher By Micah Lee, licensed under MIT version 0.3.6 https://github.com/micahflee/torbrowser-launcher QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/...
Juan Garcia's user avatar

1
2 3 4 5
3097