Category "sh"

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

shell errors running php exec

I have a PHP script that executes a shell command to find the common items between two files given. This is the beginning of my PHP script: $E7Bonded_File = "

Why does this script works on one machine but not on the other? MacOS Catalina

I have this shell script which works on my machine just fine. To test the script I have a VM with the same OS Version, MacOSCatalina. On the "real machine" the

print bash script comments when bash is executed

Assuming I have a bash script test.sh: #!/bin/bash # Comment 1 echo "Hello world" # Comment 2 echo "Hi there" I know after making the bash script executable

list of logged in unique users in linux

I am working in linux environment as a non root user. I am using users command to get the logged in users users But it returns the user names multiple times

Confirming Shell Script Input

I'm writing a script to preform a repetitive task that only changes basic values and locations such as user name. I've written up code that prompts for a usern

How to declare a var in bash without it replacing a var in a different file

I have 2 files file1 and file2. Inside file1 I declare a var, x=1. In file2 I make a var x=2. If I run file one then file two, and then in the shell echo x, I g

iterating a list of strings with whitespace in POSIX sh

I have two lists of strings (with whitespace in each string), and want to read them one by one. The length of the strings are the same, so I get the length of o

How to run a cron job inside a docker container?

I am trying to run a cronjob inside a docker container that invokes a shell script. Yesterday I have been searching all over the web and stack overflow, but I c

I just assigned a variable, but echo $variable shows something else

Here are a series of cases where echo $var can show a different value than what was just assigned. This happens regardless of whether the assigned value was "do

Jenkins does not recognize command sh?

I've been having a lot of trouble trying to get a Jenkinsfile to work. I've been trying to run this test script: #!/usr/bin/env groovy node { stage('Build

Difference between sh and Bash

When writing shell programs, we often use /bin/sh and /bin/bash. I usually use bash, but I don't know what's the difference between them. What's main difference

How can I show the wget progress bar only? [closed]

For example: wget http://somesite.com/TheFile.jpeg downloading: TheFile.tar.gz ... --09:30:42-- http://somesite.com/TheFile.jpeg

bash script to check if the current git branch = "x"

I am very bad at shell scripting (with bash), I am looking for a way to check if the current git branch is "x", and abort the script if it is not "x". #!/

Posix shell: distinguish between empty and not existing variable

In pure /bin/sh how can I distinguish between an empty variable, an unset variable and a not existing (not defined) variable. Here are the case: # Case 1: not

Posix shell: distinguish between empty and not existing variable

In pure /bin/sh how can I distinguish between an empty variable, an unset variable and a not existing (not defined) variable. Here are the case: # Case 1: not

Posix shell: distinguish between empty and not existing variable

In pure /bin/sh how can I distinguish between an empty variable, an unset variable and a not existing (not defined) variable. Here are the case: # Case 1: not

Posix shell: distinguish between empty and not existing variable

In pure /bin/sh how can I distinguish between an empty variable, an unset variable and a not existing (not defined) variable. Here are the case: # Case 1: not