Questions tagged [sh]
sh is the standard Unix shell since Version 7 Unix. POSIX has standardized shell behavior based on the Bourne Shell, and portable shell scripts should conform to the standardized syntax. Use this tag for questions that apply to Bourne/POSIX-style shells. For shell scripts with errors, please check them in http://shellcheck.net before posting here.
8,560
questions
1
vote
3
answers
42
views
Why I have to specify - sh - -c - command instead of just - command in k8s livenessProbe exec command (and potentially elsewhere)
I'm trying to exec command in livenessProbe, I have connected to the container interactively and tested the command:
exit $(test $(date +%H) -eq 3 && echo 1 || echo 0)
which produced the ...
-1
votes
0
answers
22
views
When I try to change a variable in a file I stack with error [duplicate]
I have two bash files:
1:
#!/bin/bash
PATH="/home/jk/go/src/emdr/emd_server"
sed -i 's|^COMPOSE="[^"]*"|COMPOSE="'$PATH'/docker_compose.yml"|' "$PATH/up/...
0
votes
1
answer
32
views
Does inline assigned variable followed by shell built-ins accessible by the subsequent commands?
I am trying to understand how posix shell behave when command is in the form,
# variable assignment followed by a shell built-ins.
var=value shell_builtins;
in scenario like this, posix manual says,
...
0
votes
1
answer
33
views
Shell script repeating command for 1 argument (of 3) 3 times
I'm using a shell script in a gitlab ci pipeline to update .env variables depending on the branch's context. Overall it is working as expected, except that 1 of the 3 variables is being repeated 3 ...
1
vote
0
answers
36
views
Variables set inside the rcfile are NOT accessible through Python
I've a shell script and a python script organized as follows (CAN NOT change the directory structure):
~
├── a.py
├── b
└── c.sh
The MWEs are as follows:
c.sh
#!/bin/sh
rcfile=$(mktemp)
export ...
0
votes
0
answers
15
views
"end of file unexpected" error on my sh script, how can I fix this? [duplicate]
I keep getting the error, what's wrong with my sh script?? I'm very new to this and I don't fully understand what I'm doing but this should work right?
v=0
while [1 == 1]
do
echo $v
v=`...
0
votes
0
answers
22
views
Improving a configure.ac test
In configure.ac I have the following test:
dnl $1 = MSG_CHECKING
dnl Assemble and link assembly source $2 with extra $AS options $3
dnl and extra $LD options $4. When pattern $5 is found in `objdump -...
1
vote
1
answer
71
views
How to manage non ASCII characters inside sh/bash scripts
My terminal.txt file in the sequel
shows the output of my tmpPdfFile.sh and tmpPdfFile1.sh scripts:
both scripts are unable to properly manage the file
"6._ANbertà_di_scelta.docx.pdf"
The ...
0
votes
1
answer
55
views
comparison operator syntax in posix shell
I'm trying to understand the grammar/syntax of the shell command language (to be able to parse it) and I cannot seem to find where the syntax of the comparison operations is defined.
As an example:
x=...
-1
votes
1
answer
48
views
Variable expansion in "Run" command in docker [duplicate]
Example 1:-
FROM ubuntu:latest
SHELL ["/bin/bash", "-c"]
RUN echo "export MY_VARIABLE=my_value" >> ~/.profile
RUN cat ~/.profile
RUN "source ~/.profile &&...
0
votes
2
answers
47
views
using a pipe symbol in a jq command throws an error
I am having a shell script file validation-example.sh , it has the followign content
expected_template = '{
"remoteIds": [
{
"remoteId": "",
"...
0
votes
0
answers
36
views
sh script not running inside a alpine:3.12 container when created from the image, but it is running when manually triggered inside the pod [duplicate]
Here is the Dockerfile I have used:
FROM alpine:3.12
RUN apk add --no-cache util-linux python3 py3-pip
RUN apk add --no-cache --upgrade bash
COPY 1#check_dmesg_logs.sh /usr/local/bin/check-dmesg-logs....
1
vote
0
answers
49
views
How can I test if a string contains a character in busybox sh?
I want to add an extension to a filename when it does not have one. I tried to determine whether the string contains a period but this did not work.
#!/bin/sh
dest=$2
if [ "$dest" != "....
0
votes
1
answer
56
views
How to get process filename (untruncated) from ps output?
I would like a script to be able to check if a given process is running, and also get its process ID (PID), and so I was looking at ps process output.
If I execute with the cmd option for output, it ...
0
votes
0
answers
20
views
.desktop file executing .sh script containing a docker run command not working
I have a .sh script that executes a docker run command inside of it to start a containerized application. The script when executed directly works just fine starting the container and app inside it. ...