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
1
vote
1answer
13 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
34 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
0answers
44 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
33 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 ...
2
votes
1answer
113 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?
0
votes
0answers
20 views

How is it possible to only add succeeded commands to saved shell history? [duplicate]

I'm a poor touch typist and keep running commands with typos. They fail, and I don't want that garbage in history. How to persist only succeeded commands in the command history, so that ^R/zsh-...
4
votes
1answer
168 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 ...
3
votes
1answer
129 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 ...
0
votes
0answers
31 views

MinGW bash/sh freezes 1 minute before prompt when running them as Administrator

I'm facing a real strange issue that I can't explain. I've just installed the MinGW.org (not MinGW-w64) environment on Windows 10 and everything is working as expected, except one thing: when I run ...
1
vote
0answers
235 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
1answer
96 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
0answers
39 views

Interacting with continuous netcat session from bash script

I need to make a bash script to open the netcat session, then read server messages and after every message send a response depending on the message, so the responses cannot be pre-written to a file. ...
0
votes
2answers
106 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
26 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
15 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
436 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
36 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
21 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
77 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: ...
0
votes
1answer
90 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
0answers
250 views

MacOS - Using script with launchd - startup, login, logoff, shutdown?

MacOS High Sierra I want to run this script on startup, login and shutdown, logoff. The script looks like this and is working successfully from terminal: #!/bin/sh find /private/my/tmp -mindepth 1 -...
0
votes
0answers
63 views

Need help killing an impossible-to-kill shell script

I'm trying to kill a REALLY stubborn sh process on a Linux machine, but so far I have had no success. top shows it using 95-100% CPU, and it's in running (R) state, not waiting for I/O (D) or ...
0
votes
2answers
109 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
23 views

What do I have to do to continue building the rom?

I'm trying to build a RR (Resurrection Remix) rom for my bq Aquaris X Pro, but after following the steps in this page: https://github.com/ResurrectionRemix/platform_manifest , when I typed "bash build....
0
votes
0answers
26 views

I want to have a shell script which adds a couple of screens which execute Python code

I want to have a shell script which adds a couple of screens which execute Python codeWhat the script should do is the following: Start script a which runs /home/a/exmple.sh in the same directory the ...
0
votes
0answers
65 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 ...
1
vote
3answers
644 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
2k 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
132 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
564 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
75 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
586 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
711 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
272 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
217 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 ...
34
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
269 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
67 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 ...
80
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
83 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 ...
0
votes
3answers
1k views

Quit loop if a key is pressed

I want to exit the script if any key is pressed. #!/bin/sh while true; do df -h | head sleep 10 clear done Any suggestion?
1
vote
2answers
795 views

Get intermediate nodes using ping

I need to get intermediate nodes when requesting the route through ping. I can get the intermediate routes through traceroute url, but in the server there's a problem I cannot use traceroute. I ...
1
vote
1answer
3k views

using xargs pass arguments to sub shell with pipe

I want to rename a number of files. I think I can use xargs to do it. find ./ -name "upload.log-*" ./upload.log-20180622.gz-20180624.gz-20180626.gz ./upload.log-20180624.gz-20180626.gz ./upload.log-...
1
vote
1answer
40 views

Handle filename with blank in shellscript

These are my folder structure. [set symbolic links here] /links/ [entity] /data/a 1/ #(folder name has blank) /data/b 1/ /data/c 1/ /data/d 1/ . . . I want to made symbolic link for each ...
2
votes
2answers
278 views

Shell script get email notification when the server is connected to internet

I want to check if a server has connected to the internet or not. I have tried following script unsuccessfully, which runs every 5 min and checks and sends an email if it is connected to internet. ...
1
vote
1answer
623 views

Appending new lines to multiple files

I'm trying to append new lines to multiple files with the following command: find -name *.ovpn -exec sh echo "line to append" >> {} \; before doing this, I ran a different command to make sure ...
0
votes
2answers
2k views

Command After Semicolon Not Executed in Crontab?

Here is my crontab: 42 17 * * 1-5 /bin/pkill -f 'MyExecutable.exe' ; touch /tmp/here.log And according to /var/log/cron it did run: May 22 17:42:01 server1 CROND[326732]: (myuser) CMD (/bin/pkill -...
0
votes
2answers
230 views

sh syntax to handle zero files matching a wildcard, as well as more?

I want to write a /bin/sh shell script which will handle any files matching a wildcard. It's easy to handle 1 or more matching files. However, I'm finding it awkward to handle the case of 0 matching ...
2
votes
2answers
12k views

Bash script: Create a screen session and execute a command in it

I want to write a bash file, which starts a screen session and executes a command inside. The problem is, that it first creates a session and when you manually exited the session it executes the ...