Questions tagged [sh]

sh stands for a shell. It is also often used as extension for a shell script.

Filter by
Sorted by
Tagged with
0
votes
1answer
25 views

List of JSON strings as command arguments

I've been working with GitLab CI recently to automate some busy tasks, namely auto releasing binaries for version tags. For those who don't know Gitlab CI, it is very straightforward. It pulls the ...
0
votes
0answers
14 views

python 2 sh 1.11 and sh from 1.12 to 1.14 fileno error

I am working with sh in python 2, the script works well when the version of sh is 1.11 but when upgrading the version to 1.12 and above an error occurs while running the program. The error is: ...
0
votes
1answer
297 views

“/bin/sh: 1: MY_COMMAND: not found”

Error During docker build -t MY_IMAGE_NAME ., using a Dockerfile for a ROS project, at line RUN source /opt/ros/melodic/setup.bash the following error appeared: => ERROR [stage-2 19/19] RUN ...
2
votes
1answer
33 views

sh source can't find files

I have an Ubuntu 20.04 installation. I seem unable to source files with sh, which is Ubuntu's default dash. I have a file, lets say build.env, with some environment variables in it like this: build....
0
votes
1answer
38 views

Start up shell stuck in /bin/sh how to change it back to zsh default at startup

Whenever I start my cli, it keeps starting up in /bin/sh. I've searched various different forms and none so far have worked for my issue. I also tried various options like chsh (1) <--- this only ...
0
votes
1answer
31 views

How to run drkspider.sh on windows 10

I have downloaded DRKSpiderJava v0.83 but I cannot run the file "drkspider.sh" on Windows 10. I tried with cmd, CYG, bash but don't know why cannot open it. Maybe I am doing something wrong?
0
votes
0answers
43 views

dd vs diskutil: which is faster when it comes to writing zeroes?

When I want to erase a disk, both dd and diskutil are viable options. To erase a disk with dd, I usually run something like dd if=/dev/zero of=/dev/$device bs=4096. The equivalent of this in diskutil ...
0
votes
1answer
30 views

Corrupted Files Delete in Windows [duplicate]

I am preparing a file using shell script and while doing some tests, I added the pause> nul line into my sh file. Then I ran the sh file, but there was a file named nul on the desktop and I can't ...
0
votes
1answer
33 views

Is there a `read -n` equivalent command for Bourne shell?

Is there a way to make my script wait for the user to press any key and then continue without them having to press Enter? I want to make it work in Bourne shell (sh), not Bash.
0
votes
1answer
42 views

bash vs zsh man page search feature differs

I'm switching to zsh from bash, but I just realized that when I'm in a man page in bash and use / to search, I can use the hyphen - like this: /-V and all -V occurences will be found, as expected. But ...
0
votes
2answers
137 views

Some standard commands freeze on remote machine

I'm using a remote machine (ssh connection), and some commands suddenly stopped working. By that I mean that I enter them and nothing happens: they just kind of freeze, without any output and without ...
0
votes
1answer
206 views

how to run multiple shell scripts one by one in single go using another shell script

Dear experts i have a small problem...i am trying to run multiple shell scripts having same extension(.sh) in one go, which are present inside a directory. In so far i wrote a common script like as ...
1
vote
0answers
21 views

FFMPEG Bash Script incorrectly using cover metadata instead of images

I'm trying to run a script that that is meant to convert a folder of images and a folder of audio into videos however it's pulling the metadata of the album art instead. Looking for a correction ...
1
vote
1answer
64 views

Looks like cron spawns a shell which in turn spawns a script; how can I get rid of the intermediate shell?

The OS is CentOS 7. I have a rather basic understanding of crontab and crond. I created a crontab entry using crontab -e: */5 * * * * /root/script.sh > /dev/null 2>&1 The script detects if ...
0
votes
1answer
76 views

Bash script which logs log in/log out event of users in real-time

I'm curious about bash script, which will write information to the file once any user will log in/log out to the system in real-time? Can I check it by filtering of commands from ps ps -eo user,...
0
votes
1answer
65 views

Modify a file via a script with special rights

Probably this is elementary.. Yet I didn't find an explanation to what's happening.. I have these files with these specific rights: So modtp2 is a shell script I'm using to change tp2 content with a ...
1
vote
1answer
417 views

Why isn't systemd running my ExecStartPre script?

I have two graphics cards, and need to configure xorg to use the right card based on the boot option I select in grub. To achieve this, I've added an arbitrary string to the kernel params of one boot ...
0
votes
1answer
427 views

Why is my .sh file not running in LXDE/autostart on Debian but works on Raspbian?

I'm switching from a raspberry pi (raspbian) to a tinkerboard (debian) and am unable to get the scripts running in my autostart file that I use in raspbian working on debian. On Raspbian: sudo nano /...
0
votes
1answer
49 views

Why does the value of $HOME vary between Ubuntu 18.04 & 20.04 in a script using sudo

On Windows 10 v1909, I am using WSL (Ubuntu 18.04 & 20.04: 4.4.0-18362-Microsoft x86_64 GNU/Linux) and I noticed the value of $HOME within an arbitrary script varies between Ubuntu 18.04 and 20.04 ...
1
vote
1answer
375 views

How or where to define global functions to be used in bash, zsh, sh scripts?

Say I have these three script files: (all 3 are executable) bash-test.sh: #!/bin/bash HelloFromBash RocketNuts zsh-test.sh: #!/bin/zsh HelloFromZsh RocketNuts sh-test.sh: #!/bin/sh HelloFromSh ...
3
votes
1answer
2k views

What does 'x' mean in this line #!/bin/sh -x?

Could you explain what 'x' means in the shebang #!/bin/sh -x ? Does it necessary to put '-x' in this line?
8
votes
1answer
456 views

What is the second sh in `sh -c 'some shell code' sh`?

Question I encountered the following snippet: sh -c 'some shell code' sh … (where … denotes zero or more additional arguments). I know the first sh is the command. I know sh -c is supposed to ...
2
votes
1answer
136 views

How does this find state actually work in moving a file up one directory?

Can someone explain how the string manipulation in this find statement actually works? My head is about to explode trying to figure it out. :-o From: UNIX shell scripting: how to recursively move ...
1
vote
0answers
717 views

Dash rc files for non-login non-interactive shells

Does dash have a non-interactive non-login rc file? I've read the man page, which recommends .profile for login shells and $ENV environment variable for interactive shells. Is there anything that ...
0
votes
2answers
398 views

“Access Denied” as root

I have connected to my wireless router via telnet as root. It runs on linux kernel and has busybox. / # cat /proc/version Linux version 3.4.110 (root@A23176683) (gcc version 4.7.2 (Buildroot 2013.02) ...
0
votes
2answers
167 views

showing degree symbol bash/tcl

im trying to get a login script to display degree symbol but it doesn't display it. Here is the weather.sh METRIC="1" # 0 for F, 1 for C # Fill in form to find your weather code here: # http://...
0
votes
1answer
55 views

systemd start at boot but it is stopped

I have developed a shell script : #!/bin/sh # do some treatment for i in `seq 0 10000`;do # do some treatment and create/write into log file done NOTE: my script work manually perfectly without any ...
0
votes
0answers
18 views

How can I exchange a hash password for a newer one at AIX and Linux using shell script?

We have AIX and Linux machines that we can use puppet to change password automatically. But in some cases we need to do this manually. But I decide to write a script and change the old hash with a ...
0
votes
2answers
1k views

macOS Catalina /bin/sh vs /bin/bash and showing history with preceding hash

Not really a question but an observation. When I do sys ad on Linux, I like to precede commands with a hash '#' to proof-read what I am about execute, and also to leave a breadcrumb so that I can come ...
0
votes
1answer
40 views

OK in bash, not OK in sh - convert diff < (ls) <(df)

In GNU Bash, diff <(df) <(ls) is running. In sh, it isn't. I also tried [[diff </bin/df <bin/ls]], still error: $ [[/usr/bin/diff < (/bin/ls) < (bin/df)]] sh: 1: Syntax error: "(" ...
1
vote
0answers
23 views

debian + plink on windows

i am working on a script on windows that should execute a debian .sh script when i get a [COMPLETE] line on my irc channel. But can't figure out where to put the line in my irc script. so maybe if ...
1
vote
0answers
114 views

Open VPN Install Script error (CentOS 7)

this is the error I am getting when I attempt to create a new user cp: cannot create regular file ‘/home/root/aaron.ovpn’: No such file or directory ./centos7-vpn.sh: line 984: /home/root/aaron.ovpn: ...
1
vote
1answer
126 views

sh script with Byte Order Mark

Is the Linux "sh" able to run Unicode text script files with BOM (Byte Order Mark) at the beginning? I really need this and do not want to remove BOM.
0
votes
2answers
781 views

Terminal Select multiple files and pass into .sh script

I am after writing an .sh script that lets me selective pick files within a folder and then pass those files as a variable into an .sh script so I can edit ontop of it. #!/bin/bash filesList="" for ...
0
votes
0answers
89 views

How to derive CPU usage values over time on Neutrino OS?

I have access to the basic shell on /bin/sh QNX Neutrino OS (6.4.1) I want to plot a graph of CPU usage (increase or decrease) over time. The data values can be percentages. I have tried certain ...
2
votes
3answers
1k views

Error while running ./file.sh in MacOS: ss command not found

While running ./file.sh or sudo sh file.sh i get the error ss command not found. Also tried chmod u+x file.sh I use MacOS Image showing the error
1
vote
1answer
4k views

Using 'cut' command on Windows

I am trying to run this command line on Windows (I've installed GNU coreutils 8.24) echo android:versionCode="3267" | cut -d \" -f 2 Expected output: 3267 However, I am getting error: cut: the ...
2
votes
1answer
344 views

Parameter expansion (variable expansion) and quotes within quotes

While working in a (Unix) shell, sometimes I need to double-quote single-quotes or vice versa, i.e. to write something like "foo 'bar baz' moo" or 'foo "bar baz" moo'. This may be because the ...
1
vote
0answers
761 views

How to suppress “stty: standard input: Inappropriate ioctl for device” in Jenkins console

I use PHPUnit with Jenkins. PHPUnit outputs many "stty: standard input: Inappropriate ioctl for device." like this [***] $ /bin/sh -xe /tmp/jenkins3872195701082406677.sh  + vendor/bin/phpunit tests/ ...
0
votes
1answer
39 views

How to launch couple of .sh in one command?

I have some files in a folder and want to launch them in one command. Structure looks like this: keddad@keddad-HP:/media/$ ls somfile.sh otherfile.sh onemorefile.sh So I'm trying to do it with a ...
0
votes
0answers
153 views

How to run a command when any process starts?

I have an sh script to update my wallpaper which uses pscircle in order to display running processes. The script runs every five seconds to update the wallpaper, but I would like it so that the script ...
1
vote
1answer
938 views

How can I use a “here document” in the middle of a pipe?

I am wanting to generate some content using a heredoc as a template: passphrase=$(<passphrase) envsubst <<EOF apiVersion: v1 kind: Secret metadata: name: openshift-passphrase stringData: ...
2
votes
1answer
1k views

Bad number error with Linux float variable value comparison operator condition

I'm trying to test some logic on an Antminer S9 where I get the output of a command and then from that output I grab a specific float value so I can then put this value into a variable and process ...
2
votes
2answers
541 views

Find filenames with uppercase extension

How can I find all the files with their extension in uppercase in recursively in a directory. I've tried : $ find -name "*.[A-Z][A-Z][A-Z]" Seems to work but of course this does not check files ...
1
vote
2answers
299 views

Is it POSIX-compliant to use a shell function in a pipeline?

Is it possible to use a shell function in a pipeline? Say I had a function that acted like grep, called mygrep. Is there any way, using only POSIX shell features, to be able to invoke mygrep like ...
35
votes
2answers
5k views

What is wrong with “echo $(stuff)” or “echo `stuff`”?

I used one of the following echo $(stuff) echo `stuff` (where stuff is e.g. pwd or date or something more complicated). Then I was told this syntax is wrong, a bad practice, non-elegant, excessive, ...
2
votes
1answer
449 views

Grep regex result not as expected?

Using FreeBSD 11.1: #!/bin/sh if printf 'abcde.fgh' | grep -iEq '^[^][$^*_-]'; then echo "test 1 success" else echo "test 1 fail" fi echo if printf 'abcde.fgh' | grep -iEq '^[^][.$^*_-]'; ...
0
votes
1answer
70 views

Raspberry Pi headless, my if [[ file1 -nt file 2 ]] that thinks the two files have the same modified date

So I have a player script "player.sh" and an updater script "updater.sh". player.sh plays any mp3 file in /home/filepath/ using a wild card *.mp3, this works as expected. what I want is for the ...
81
votes
1answer
7k views

Is redirection with `>>` equivalent to `>` when target file doesn't yet exist?

Consider a shell like Bash or sh. The basic difference between > and >> manifests itself in a case when the target file exists: > truncates the file to zero size, then writes; >> ...
0
votes
1answer
110 views

Bash modifying text between marked lines

I have a file with more than 8000 rows. File is divided into sections, each section is labeled with text like ##C, ##T,##N. I have to modify some rows in the file. I used command SED to mark lines ...