Questions tagged [sh]
sh stands for a shell. It is also often used as extension for a shell script.
212
questions
1
vote
3
answers
69
views
Using read -r within in-line shell scripting
I have a file that contains a list of absolute paths of several files. I need to move all of the files listed in the file to another directory. Unfortunately, I have to do this using in-line shell ...
1
vote
1
answer
62
views
How to create abnormal amount of subdirs?
I want to create 1000x1000x1000x1000x1000, etc. directories, but something like mkdir -p {1..1000}/{1..1000}/{1..1000}/{1..1000} gives to many arguments error or just infinitely eats my RAM... How can ...
0
votes
1
answer
71
views
Bash script vs command line
I have started working on bash scripts.
I have just observed a difference between executing a command line and executing the same commands but inside a script. In particular the command line is:
for a ...
0
votes
0
answers
113
views
I have not captured a screenshot using the service
I am using a shell script and I want to run the script automatically when the system is ON/Restart without opening any application.
Here is my script.sh file:
while sleep 5
do
scrot 'myimage.png' -e '...
0
votes
2
answers
746
views
How do I use xargs to pass arguments as $1, $2, $3, ... to an inline script called with sh -c?
I want to pass tokens a b c as arguments of a script that will output a - b - c.
If I have a script dummy.sh that does echo "$1 - $2 - $3" and a dummy.dat file containing :
a b c
d e f
and ...
0
votes
0
answers
141
views
Why does Windows `perl` fail to acquire environment variables when run under `sh` over SSH?
Overview
I have a puzzling problem where a command I run behaves differently when run over SSH compared to run directly on the machine (via RDP). I have narrowed the issue to a Perl script in which ...
0
votes
1
answer
404
views
Execute Script Via SSH And Disconnect Immediately
The idea is to connect to a remote machine via ssh and execute a shell script without waiting for it to finish.
EDIT: The issue was ssh, not nohup.
0
votes
1
answer
3k
views
How to use git pull with Jenkins sh steps?
git pull doesn't work with Jenkins for some reason.
I've updated some files on my local PC and pushed it to my Github. I can see the changes there. Then I run Jenkins build that has sh commands to ...
0
votes
0
answers
138
views
I installed LuaRocks via Homebrew, and it's not working
I just installed LuaRocks, the standard package manager for Lua, using Homebrew:
brew install luarocks
I'm running Lua 5.4, and every time I try to access the package repository, either to search or ...
0
votes
0
answers
115
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.
3
votes
1
answer
374
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
54
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
164
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
1
answer
160
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
49
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
274
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?
1
vote
1
answer
1k
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
392
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 ...
2
votes
1
answer
33k
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 ...
3
votes
1
answer
1k
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
272
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
56
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
110
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
116
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 ...
1
vote
1
answer
380
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
90
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
201
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
1k
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
40
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 ...
3
votes
1
answer
618
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
368
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
78
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
2k
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
2k
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
112
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 ...
4
votes
1
answer
3k
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
10k
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?
11
votes
1
answer
1k
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
155
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 ...
2
votes
0
answers
904
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
1k
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
527
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
198
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
62
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
50
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
40
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
124
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
309
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 ...