Questions tagged [sh]
sh stands for a shell. It is also often used as extension for a shell script.
204
questions
0
votes
0
answers
20
views
MSYS2 - Change to /bin/sh
How would I switch my default shell from bash to sh in MSYS2? Even just trying to do something as simple as pacman -S sh tries to install bash.
1
vote
1
answer
45
views
/bin/sh is symlinked to bash, but completely different?
If I do ls -l /bin/sh:
I get
lrwxrwxrwx 1 root root 4 Jan 9 00:01 /bin/sh -> bash
However, when I start sh, I get a completely different prompt than I would, my ~/.bashrc isn't sourced, and if I ...
0
votes
1
answer
20
views
Sending FreeBSD script output by email loses format (left aligned and right aligned in one line)
every day I am running a script on my router to check the traffic usage of a specific server. The script is working fine and with this output part of the script, I get following result:
#Give output
...
0
votes
1
answer
82
views
How to copy hidden file names to a text file in unix?
I have several directories which contain hidden empty files. I need the name of these file names themselves, so I need to write the filenames to a txt file.
My script looks like this:
cd /z/...
0
votes
0
answers
14
views
getting .sh file to run in cron
I wrote test.sh file to get to run helloworld.py every minute.
test.sh is the following:
#!/bin/sh
python3 helloworld.py
I ran chmod +x /home/blackwidow/Desktop/test.sh in the command as well to make ...
0
votes
1
answer
31
views
Windows : launch .sh using environment variable
i'm trying on windows to launch my server from anywhere in my computer (start_server.sh).
Launching my file containing those line manually works fine (using GitCMD) (probably not the best, i'm of ...
1
vote
2
answers
42
views
Creating multiple symlinks from a string
I have the following script:
#!/bin/bash
test="../t1,../t2,../t3"
ln -sf "{${test}}" .
Above this directory consists of 3 directories:
../
├── script
│ └── test.sh
├── t1
├── ...
0
votes
1
answer
96
views
Why is sudo able to run in fakeroot?
Take the following snippet:
fakeroot -- sudo cat /etc/shadow
This will print out the contents of /etc/shadow, but doesn't running sudo in fakeroot ruin it's whole purpose, or am I missing something?
0
votes
1
answer
175
views
Rsync creates empty folders
I have following directories. My goal is to compare OLD vs NEW directory and save the different files in the DEST directory:
OLD/
...src/
...src/config.js
...test/
...test/main.js
NEW/
...src/
......
0
votes
1
answer
95
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
1
answer
13k
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
1
answer
150
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
1
answer
128
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
1
answer
45
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
0
answers
59
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
1
answer
55
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
1
answer
97
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
1
answer
65
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
2
answers
151
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
1
answer
419
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
0
answers
28
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 ...
2
votes
1
answer
202
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
1
answer
155
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
1
answer
71
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
1
answer
1k
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
1
answer
1k
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
1
answer
52
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 ...
2
votes
1
answer
1k
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 ...
4
votes
1
answer
4k
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?
9
votes
1
answer
734
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
1
answer
144
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
0
answers
786
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
2
answers
703
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
2
answers
257
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
1
answer
129
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
0
answers
27
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
2
answers
2k
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
1
answer
44
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
0
answers
29
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
0
answers
119
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
1
answer
151
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
2
answers
2k
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
0
answers
124
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
3
answers
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
1
answer
5k
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
1
answer
1k
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
0
answers
922
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
1
answer
41
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
0
answers
246
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
1
answer
1k
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:
...