Category "bash"

Get exit status of a process in bash

I have a c++ executable named Test. I want to find out the GetExitCodeProcess() code when the execution is completed. I can find out the status code by writin

Update global variable from while loop

Having trouble updating my global variable in this shell script. I have read that the variables inside the loops run on a sub shell. Can someone clarify how thi

Count character difference between two files in bash

What would be the best way to count the number of characters that are different between strings in two files. I know how to do this in Python but I need a bash

Bash program that returns 1 on input and 0 otherwise

Is there a standard linux terminal program that when given text input (in standard in) returns a 1 and 0 if no text is provided? (The reverse logic would also b

Find lines in a file that has only words in a list

Here is file1.txt: .apple .ball .cow .apple .cow .tea .mine.nice .mine.nice .tea .zebra Here file2.txt .apple .mine.nice .cow .tea Expected Result: .apple .co

Dockerfile RUN command multiple inputs

I have a Dockerfile using which I am trying to build an image. I wish to have multiple inputs fetched from the user from STDIN, when the build runs. To get star

Add a waiting point in a heredoc block running on a remote server

I am trying to add a waiting point to my code which can then be resumed/unblocked manually. Sadly it is not working as expected. I guess due to how heredoc work

Bash -a vs bash && [duplicate]

I have this bash statement: if ls > /dev/null 2>&1 -a ls > /dev/null 2>&1; then echo "true"; else echo "false";

Regex: why can't I use a capture group inside curly braces {}

I want to replace the nth charater of a line to '.', with n being line dependent and can be provided on the line itself, e.g. a example file can look like this:

Merging CSVs into one sees exponentially bigger size

I have 600 CSV files of size ~1Mo for a total of roughly 600Mo. I want to put all of them into a sqlite3 db. So my first step would be to merge them into one bi

Download a specific folder from on-prem GitLab

I have an on-prem GitLab with a huge repository with many folders. I'm trying to create a freestyle Jenkins job that would only retrieve the folder from the rep

Running shell command that has nested quotes via ssh

I have this following shell command: ssh user@host "df | grep /dev/ | \ awk 'BEGIN{print "DISK", "%USAGE", "STATUS"} {split($5, a, "%"); \ var="GREEN"; print $

printing output of ls | wc -l in a txt file with two columns

I have many directories with different number of CSV files in each of them. I am interested in getting a list of those directories with a their respective numbe

Bash command to search pattern (sequence) and print everything what's next to the pattern (to the right and left side)

I'm trying to reconstruct a gene sequence based on a PoolSeq file of a population (fasta format) and a conserved area. I want to search the file for matches wi

docker copy and chown in bash script

I'm building a network with docker compose and some bash scripts and i'm having problems during the process. Basically i have a some containers and volumes. In

Submit slurm job script in sub-folders

I have multi sub-folders (say 1,2,3....) inside a parent folder (say A,B,C....). Each script contains ".sh" file and associated loading files. What would be the

Why am I getting gibberish result in Windows terminal?

I am trying to compare version in windows terminal. It works great in Git Bash but in Windows terminal it shows gibberish and wrong result? verlte() { [ "$

How to replace 00 with Na excluding first row & first column using bash in comma separated file

I'm working with GWAS data, My data looks like this: IID,kgp11004425,rs11274005,kgp183005,rs746410036,kgp7979600 1,00,AG,GT,AK,00 32,AG,GG,AA,00,AT 100,TT,AA,00

Can I pass a literal $ into a bash script from the command line?

I'm creating a bash script and I need to be able to accept a string as the first parameter. This string may contain the $ character. Script #/bin/bash pass="$1"

How to post multiple images to mastodon using api with bash curl

I'm starting to learn to use rest api via bash curl by writing a simple mastodon bot. I can attach multiple images using curl https://example.com/api/v1/statuse