Category "bash"

Combining mapfile, command redirection and exit status retrieval

I am reading a build command as so: mapfile -t make_out < <(2>&1 ./make.sh my_program) I would like to print the output kept in make_out only if t

ignoring specific exit code in bash

Note: Question does not duplicate Ignoring specific errors in a shell script . Suppose it is needed to capture the leading characters of a encoded representati

How to overwrite a multiline string in bash?

I have this code snippet, which allows to overwrite a string in bash if used multiple times: echo -ne "String 1 \r" echo -ne "String 2 \r" Output: String 2

How to find the location of a bash file?

I've made an executable .jar file for a terminal game I've been working on. So far, I opened it by typing java -jar name.jar in the Terminal. This worked, but w

Can't Run Go Bin In Terminal

I have been executing my Golang code on Visual Studio in the terminal for the past few weeks. All of a sudden I am trying to run a program I made, and it does n

Can't Run Go Bin In Terminal

I have been executing my Golang code on Visual Studio in the terminal for the past few weeks. All of a sudden I am trying to run a program I made, and it does n

How to be explicit about intentional word splitting?

I'm running shellcheck on my scripts and often get this warning (which in this case is correct, because cd foo bar baz makes no sense): cd ${SOME_DIR} || exit 1

How can I loop with all the nc -zv connections?

I am trying to write a script to monitor all the server ports. But I am able write to for only one connection at a time. How can I write it for all the connecti

Bash completion scripting - getting a "transparent proxy"-like behaviour

I am trying to write a simple Bash completion script for a program that runs its arguments as a command. A good example of this is kind of program is the prime-

Counting lines of code in a Django project

I use this shell script to count the lines of code in a Django project, find . -name "*.py" -type f -exec grep . {} \; | wc -l How can I modify this to not c

How to convert a json response into yaml in bash

I read data from a json file with jq. I wanna append the results into a yaml file, but I dont get it working. I am quite new to shell programming. My goal is to

Execute bash script from Python on Windows

I am trying to write a python script that will execute a bash script I have on my Windows machine. Up until now I have been using the Cygwin terminal so executi

rename files with changing pattern

i want to rename different files in bash with pattern and found this option: rename 's/.2007/(2007)/g' *.* with this pattern I can rename every file with "

Gitlab CI/CD - sending comments/alerts to the gitlab UI?

Currently I have this line in my .gitlab-ci.yml file: if (( $coverage < $MIN_COVERAGE )) ; then echo "$coverage% of code coverage below threshold of $MIN_COV

Shortest non-null bash quine

The shortest bash quine is the null string: $ bash -c '' $ What is the shortest non-null bash script which produces its own source code as output?

update value in bash script

i have stuck code. i make bash script to send Notification If file Size changed #!/bin/bash #File Embeded test_file=/home/optimus/bot_test/dump.txt msg_captio

update value in bash script

i have stuck code. i make bash script to send Notification If file Size changed #!/bin/bash #File Embeded test_file=/home/optimus/bot_test/dump.txt msg_captio

How to get information from a while loop after a pipe in bash

From this trivial example: $ x="ls output: " $ ls | while read line; do x="$x $line"; echo $x; done ls output: a ls output: a b ls output: a b c ls output: a b

How do I set a variable to the output of a command in Bash?

I have a pretty simple script that is something like the following: #!/bin/bash VAR1="$1" MOREF='sudo run command against $VAR1 | grep name | cut -c7-' echo

zip error - Nothing to do

I try to zip all folders in given directory. So I wrote this find /home/user/rep/tests/data/archive/* -maxdepth 0 -type d -exec zip -r "{}" \; but got zip e