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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
35 views

RunLinuxScript from SQL Server on Linux server using JOB

Product: Microsoft SQL Server Operating system: Ubuntu (20.04) Platform: Linux I am moving from SQL over Windows to SQL on Linux. Previously I use @subsystem = N'CMDEXEC' when try ...
user1932675's user avatar
0 votes
1 answer
71 views

How to understand the "$0" "$@" after `exec python3 "$0" "$@" `

I do not quite follow the following code snippet from https://github.com/nodejs/node/blob/main/configure#L6-L16. In particular, what does "$0" "$@" mean right after sh -c ```<...
Lala James's user avatar
0 votes
0 answers
18 views

service (that run sh file) file do not write content to file

I have a service file that run a sh file Inside sh file i run js file that just console.log some content (for test) But when i open the path (it successfully create the folder and file too), there no ...
Tuấn Anh Bùi's user avatar
0 votes
0 answers
52 views

How to detect a program for all Linux (BASH, ASH and SH) without extensions such as "[" or "type"? [closed]

Tried "type" (was told from search results to run "type",) but "type" had problems, and was told that "type" won't run on all Linux. Tried: HasJava=$(type javac ...
user17576136's user avatar
0 votes
0 answers
17 views

Cat files in Hadoop that do not end with gz [duplicate]

I am trying to cat files that are not gz hdfs dfs -cat /*.gz How do I cat all files that do not end with .gz?
Utkarsh Goel's user avatar
0 votes
0 answers
9 views

HasJava=$(type javac || (type ecj && type dx))\nif $HasJava; then /*stuff*/ runs stuff with or without Java [closed]

From How can I check if a program exists from a Bash script? : Do not use "which"; just "type" runs on all Linux From How to find whether or not a variable is empty in Bash : must ...
user17576136's user avatar
0 votes
0 answers
35 views

Why sh script works only after CTRL+Z?

I'm using this sh script under MacOS to send files over the serial port. When I run it, it does not work at once. I've to stop it with CTRL+Z and relaunch it. I cant figure out why it only works after ...
elpekos's user avatar
  • 11
-1 votes
0 answers
26 views

How do I set environment variables for JetBrains apps?

In version 13.4, Apple banned the use of launchctl setenv unless you have SIP turned off. I used it to set variables for JetBrains applications to catch my settings from custom vmoptions. But since 13....
j1s1's user avatar
  • 1
-2 votes
0 answers
25 views

"HasJava=`type javac || (type ecj && type dx)`\n$HasJava && echo 1" and "HasJava=`type NotExistAsdf`\n$HasJava && echo 1" both echo "1" [duplicate]

Can add ">/dev/null 2>&1" but got an error. How to echo 1 for terminals that got Java, and not echo for terminals that do not got Java? ~/java $ type javac javac is hashed (/data/...
user17576136's user avatar
3 votes
1 answer
48 views

Why does `if [false]` evaluate to true but `if false` doesn't in bash?

Running this script in bash will print "hello" if [ false ]; then echo hello fi Running this script in bash will print "hello" if [[ false ]]; then echo hello fi Only ...
notacorn's user avatar
  • 3,598
0 votes
1 answer
35 views

print command output stored in bash variabled as it with wothout removing new line [duplicate]

i just want to write a bash program that stores top 5 process on variable as it is without removing new lines. #!/bin/bash getTopProcess(){ top_output=$(top -n 1 -b -o %CPU | awk 'NR>=8 &&...
Kavin Kumar's user avatar
0 votes
0 answers
28 views

How to create an array of Kafka topics using KSQL and bash

I want to delete topics at the start of my script but want to make sure the topic actually exists before deleting to prevent error. My thinking was to create an array of all topics and then to loop ...
goober's user avatar
  • 3
0 votes
1 answer
42 views

How do i execute a multi line command through docker compose?

I want to execute the following command inside my docker container through docker compose cat <<EOT >> /config.toml [[tls.certificates]] certFile = "/etc/letsencrypt/live/example....
Sachin's user avatar
  • 1,219
0 votes
1 answer
38 views

Shell script - Filter data from log file which having actual process count value [closed]

I have one following log file (input-data-file.log) and i want to do some filter on input file using shell script (.sh) which give me output which having actual count >0 value (Exclude 0 (zero) ...
Kirtee Chaudhary's user avatar
0 votes
0 answers
29 views

"read" command does not wok in /bin/sh script

I need to read output of one command into variables. Here is simplified examle: #!/bin/sh echo AAA BBB | read X Y echo $X this echos empty string. Whereas when i use /bin/zsh as shell, it works as ...
Martin Vegter's user avatar
0 votes
3 answers
58 views

Replacing the text that follows a given word [duplicate]

I need help with replacing the first line in the file that follows a given word (which will not be repeated). I have a file with content: "text1" { "text2" "0" &...
Paweł Selen's user avatar
1 vote
2 answers
58 views

Shell script program - Filter rows from log file which having disk-space utilization size more than 80%

I have one following log file (input-log-file.log) and i want to do filter on log file using shell script (.sh) which give me rows which having disk space utilization more than 80% (>= 80) along ...
Kirtee Chaudhary's user avatar
-1 votes
1 answer
37 views

In docker can't use tree command, get error: /bin/sh: 52: tree: not found

I'm using docker, I want to use tree command, but I get error: # tree -L 1 /bin/sh: 52: tree: not found # whereis tree tree: # apt install tree Reading package lists... Done Building dependency tree ...
Tom's user avatar
  • 461
1 vote
1 answer
54 views

How to compare folders size in bash/sh?

I am building a simple caching script in bash. Let us assume we have the folders source dest I want to write a if condition and check if the total size of source matches the total size of dest (by ...
Kristi Jorgji's user avatar
-1 votes
1 answer
51 views

Problem running loops in shell script via ansible

I'm having problems when I try to run a .sh on servers via Ansible, when running the playbook, all instructions that are executed other than the loop are executed, but the loop commands are skipped ...
fkessl's user avatar
  • 1
-1 votes
1 answer
56 views

How to launch executable file from website with php?

I want to launch (not install) an .apk/.bat/sh files when clicked on the website in the Without warning or downloading. I found that codes in php offical website: <?php $WshShell = new COM("/...
Oven Kravecki's user avatar
-1 votes
1 answer
68 views

Replace New Line with blank inside the AWK

#Removing single quote from file to avoid conflict with delmiter roledetails="${roledetails//","/"|"}" awk ' BEGIN { FS = ":[[:space:]...
Lord OfTheRing's user avatar
-2 votes
1 answer
24 views

Required shell script to modify json data [closed]

I am new to shell scripting, I need help in converting python code to shell script. # Your JSON data data = { "group1": [ {"key1": "val1", "key2": &...
New Progrommer's user avatar
0 votes
0 answers
37 views

shell scripting issue syntax error in expression

where is the Issue ?? #!/bin/bash echo "your home dir is ${HOME} your hostname is ${HOSTNAME} your user name is ${USER} " y="programmer" echo "i wil be what i want\ i whant ...
DSL's user avatar
  • 1
0 votes
1 answer
40 views

Getting "( unexpected" syntax error - Script works in one instance but not another [duplicate]

#!/bin/bash PS3="Select an install package: " items=("Essentials - VLC" "Graphics Suite - Inkscape, GIMP, Blender" "Streaming Suite - OBS, Openshot, ...
AJSarley223's user avatar
1 vote
1 answer
36 views

What is the simplest way to parse a json string in linux console? [closed]

I need a simple way to parse a json string received as a parameter. Is there a console tool for doing that? I'll like to have something like this: data=parsestring('{"field1": "value1&...
juanheredia's user avatar
3 votes
5 answers
86 views

Find and display only multiple name match

I need to use bash to strictly match multiple folders names and display these folders. In that example folders with subfolders. root_folder sub1 sub2 root_folder1 sub1 sub2 sub3 ...
Katrin Izengard's user avatar
-1 votes
1 answer
27 views

How to call java class from project B in project A

I'm trying to move a class from project A to project B (which is in Maven dependencies of the project A) to reuse it in other pet projects. Currently, this class calls from project A in a Jenkins ...
Юрий Барсуков's user avatar
0 votes
1 answer
45 views

scr.sh: 3: Syntax error: word unexpected (expecting ")")

I'm doing a task, but I got an error: scr.sh: 3: Syntax error: word unexpected (expecting ")"). When I try to run my schell script on my local computer server, it works, but on the helios ...
Camilla_T's user avatar
1 vote
1 answer
16 views

service app stop after running a script.sh

I have a container that has a serivce app, that is built with a dockerfile. services: app: build: docker Inside my docker file i have at the end, a script.sh that i run to initialize drupal ...
Haamome's user avatar
  • 95
0 votes
0 answers
24 views

xargs command behaving abnormal | Unix

I have a Redhat servers server 1 and server 2 . Both are having same configuration and properties set. Even the file and folder setup is also same. We receive 2 files on both server 1 and server 2 ...
zud31507's user avatar
1 vote
1 answer
43 views

How to read array records with specific header name

I have specific records as below in one array $rolerows each record delimited by new line: name roleTemplateAppId roleTemplateName ...
Lord OfTheRing's user avatar
-3 votes
1 answer
65 views

Mac Environment Variable Not Detected If Using .sh File

Mac Environment Variable works on Terminal but Not Detected If Using .sh File I have script to build Unity libraries which using .sh and the script need Android sdk, so I add Adroid sdk path to ...
Isma Rekathakusuma's user avatar
0 votes
0 answers
8 views

find command with dynamic binding variable is not working for remote server

Trying to generate checksum for all files that are present in directory for remote system using below ssh root@$host1 'find /foo/ -type f -exec md5sum {} + >/tmp/checksum.txt;' File /tmp/checksum....
Ganga's user avatar
  • 31
0 votes
0 answers
20 views

How to containerize a single node app from a mono-repo that utilizes npm workspaces

I have a mono-repo with 4 node packages: / └── apps ├── app1 ( "dependencies": { "lib1": "../../libs/lib1" } ) └── app2 ( "dependencies": { "lib2&...
Forivin's user avatar
  • 14.9k
0 votes
0 answers
23 views

Bash: Why does K get appended to the end of base64 encoded value when running via script? [duplicate]

If I encode via $#:> echo -ne "Apps:apps1" | openssl enc -base64 QXBwczphcHBzMQ== but if i write a script for the same in temp.sh file. #!/bin/sh echo -ne "Apps:apps1" | ...
Sujay Kumar's user avatar
1 vote
1 answer
35 views

Shell Script Spinner Shows the PID

I'm trying to fake show a spinner when I "need" to run a long running piece of code (ok, so, it isn't long running, but I want it to seem that it is to my end user...) On Android 12+ So, I'...
Kevin's user avatar
  • 2,694
0 votes
3 answers
61 views

Ensuring that a SIGINT does not prevent following commands from executing

I know it's possible to use cmd1;cmd2;cmd3 to execute commads sequentialy, but in the case the first command is executing and it receives a SIGINT, the other commands do not execute. For Example: ...
Hugo Corrá's user avatar
  • 14.6k
0 votes
1 answer
25 views

Docker Run: How to run .sh script from url?

I am new to Docker and trying to install NordVpn inside Docker Container by running the .sh script listed in their documentation. Below is my dockerfile and the error I am getting when running this ...
Cody Nolf's user avatar
2 votes
2 answers
75 views

JSON escape CURL/JQ output

From API I get JSON that has a string fields with multiple lines and different escape characters. I try to both output this JSON and get one of it's values. I tried different combinations like this: ...
Александр М's user avatar
0 votes
0 answers
43 views

Parse netcat output before sending?

For experimental and educational purposes, I am creating an extremely small and simple web server using only netcat. currently i have HTTP_RESPONSE="HTTP/1.1 200 OK\n\n Hello" { echo -ne &...
Cardeal Russo's user avatar
0 votes
0 answers
10 views

While creating Image in ECR using Codebuild I have below issue

Below is error details [Container] 2023/08/25 16:10:25 Command did not exit successfully bash $CODEBUILD_SRC_DIR/docker_python/scripts/build_and_push.sh $DOCKER_IMAGE_NAME exit status 2 [Container] ...
Ketan Patil's user avatar
0 votes
1 answer
28 views

Script at specified location: failed to close STDERR

I have a script that gets the following error: Error InstanceAgent::Plugins::CodeDeployPlugin::HookExecutor: Script at specified location: scripts/powwow-deploy.sh failed to close STDERR Script at ...
Richard's user avatar
  • 8,233
0 votes
0 answers
41 views

Shell script to do version increment

I need to increase the minor version by 1 using sh command if the branch is release. Expected result in below code is 12.3.6 #! /bin/sh BRANCH='release/12.3.5' echo $BRANCH | awk -F"/" '{...
Shabar's user avatar
  • 2,629
0 votes
2 answers
75 views

For every environment variable, create an environment variable with the base64 encoded value

For certain environment variables (*_PASSWORD), I want to create a second environment variable containing a base64 encoded copy of that variable (*PASSWORD_B64). I have a working solution for bash, ...
user179157's user avatar
-2 votes
1 answer
51 views

Linux shell: What does -f do? [duplicate]

I have a linux .sh file with something like: scripts_dir='/opt/myapp/scripts' [ -f "${scripts_dir}/common.sh" ] && . "${scripts_dir}/common.sh" scripts_dir defines a ...
Mandroid's user avatar
  • 6,356
0 votes
0 answers
16 views

Run a Script from AutoSys Blob/Glob

I want to run a shell script on different machines with an AutoSys CMD job. However, I cannot put the script on each machine. I tried pushing the script as blob and glob as stdin to sh command. ... ...
Gerulf Lavrentios's user avatar
0 votes
0 answers
20 views

Declare an array in a shell script [duplicate]

On the command line you can declare an array as # a=() but in inside a script #!/bin/sh a=() echo "length is ${#a[@]}" it doesn't work. # sh ./array.sh ./array.sh: 3: Syntax error: "...
Richard Barraclough's user avatar
0 votes
2 answers
38 views

Convert simple powershell script to Linux script

On our build server, I'm adding the build number to the AssemblyInfo.cs file. The script finds the current version in the AssemblyInfo.cs file, then appends the build number, then overwrites the ...
jsirr13's user avatar
  • 944
0 votes
3 answers
68 views

Linux shell: remove lines from an file reading another file

Let's consider 2 text file, one 'main_list', and one 'ignore_list'. For each line in the ignore_list, I want to remove the line starting with that string in the main_line. basically something doable ...
EricBDev's user avatar
  • 1,309

1
2 3 4 5
171