Questions tagged [sh]

/bin/sh is the POSIX shell. For questions where portability is important. If the question is about .sh files, tag it with `scripts` instead. On Ubuntu the POSIX shell is symlink to `/bin/dash`, and [dash-shell] is therefore related to [sh] tag, and both may be used when tagging questions.

Filter by
Sorted by
Tagged with
0 votes
2 answers
74 views

How to launch multiple Gnome-terminal windows in a shell script and continue only after these have finished

In a script, I want to launch a number of Gnome Terminal windows, and then proceed with the script only when the windows are closed. I have a shell script containing: command 1 gnome-terminal ./...
user avatar
1 vote
1 answer
47 views

Bad substitution

I am writting a shell script which will monitor the folder "/home/Folder" and it will call the script.py when it found the file format 1234567.csv file. inotifywait -m --format '%f' -e ...
user avatar
  • 13
0 votes
0 answers
15 views

Continue sh script after accessing root [duplicate]

I execute a sh script in terminal which backs up some folders. However, these folders are contained within the /var/www/ directory. I use sudo -i to access this directory but when it's executed in the ...
user avatar
  • 1
0 votes
1 answer
74 views

Cannot run bash script

I tried to make a bash script to open a file in VS code but it is giving the error: Bash: ./open.sh: Permission denied This is the script: #!/usr/bin/bash code $1
user avatar
0 votes
0 answers
17 views

'cd' doesn't work with the value, received from 'read' statement in shell script [duplicate]

I wrote shell script, where I ask for input from the user: read -p "Please enter the value" VALUE But when I try to cd into $VALUE, received from read, I get an error: bash: cd: ~/omg/: No ...
user avatar
  • 1
6 votes
1 answer
544 views

my ubuntu shows shell script echo in strange way

Hi I have a file with shell script which looks like this #!/bin/bash todayDate=$(date) echo "Today's date is ${todayDate}. have a nice weekend!" but when I call this file in my ubuntu ...
user avatar
3 votes
1 answer
261 views

Unable to install a .sh file

I am trying to use a package called mgl-tools and when I run ./install.sh, it isn't working. It used to work a few days ago. The error: ./install.sh Installing MGLTools to /home/aka/Desktop/Expt 10/...
user avatar
  • 45
2 votes
0 answers
144 views

How to merge multiple video files with different codecs? MP4/H.265

I have a very very very ugly script to merge multiple files of my football games (I have 10 cameras a game) and now I am starting to make highlights of each game. But some of the cameras have ...
user avatar
0 votes
0 answers
174 views

About installing .sh Ubuntu 20.04

I'm trying to install this file .sh https://github.com/greatfire/website-mirror-by-proxy/tree/master/install I used these command line chmod +x install.sh sudo ./install.sh after that it show me ...
user avatar
  • 11
0 votes
1 answer
302 views

How to create calculator with bash?

How to create calculator with bash ? example read -p "calculator count: " calc echo '$((calc))' | bc i input 2+2 output (standard_in) 1: illegal character: $ how to fix ? I just ...
user avatar
4 votes
2 answers
3k views

Script to run a command in a terminal and then open a new terminal tab and run another command

I am running Ubuntu 21.04 and I want to create a script, that would do the following: Run: cd && cd path/to/repo && git pull && npm i && code . && npm run dev ...
user avatar
0 votes
0 answers
27 views

When i run this game via ./ it tells me to change directory?

leo@leo:~/Public/Tesla Sim Linux$ ./Tesla-Sim-Linux.x86 Set current directory to /home/leo/Public/Tesla Sim Linux Found path: /home/leo/Public/Tesla Sim Linux/Tesla-Sim-Linux.x86 Mono path[0] = '/...
user avatar
1 vote
1 answer
95 views

How to make shortcut for .sh file?

I have a file called RunRoR.sh i have enabled it to be executed and run as a software but when i double click it it doesn't do anything so in order to run it i have to do ~$ sh RunRoR.sh Can i create ...
user avatar
1 vote
1 answer
3k views

bin/sh: 1: source: not found

I am trying to install fpylll from a repository on Ubuntu 18.04 The fpylll instruction in README.rst says that after Automatic install you should do $ source ./activate but I get a notification: / ...
user avatar
3 votes
2 answers
632 views

Shell script keeps executing even if was true

I have a simple shell script to check if the user exist, if not, add that user #!/usr/bin/bash echo "Enter user" read -r user if [ "$(id -u "$user" &>/dev/null)" = ...
user avatar
0 votes
1 answer
70 views

Can't access my VPS through SSH

I just misconfigured my /etc/passwd had used this command on root login root@ubuntu:~# sh -c 'echo "nope no entry mates" > /etc/passwd' Now whenever I try to access my VPS though any ...
user avatar
0 votes
0 answers
34 views

Shell script that runs python script again when it's finished [duplicate]

I want to create a sh script that runs python script python core.py and when the script is finished pause for some milliseconds and run it again. And so on and on. Not sure where to start - any help ...
user avatar
  • 101
0 votes
2 answers
124 views

Running .sh file with one button click

I am a linux beginner and I am trying to automate a small task on my computer. In order to connect to my vpn, I have to open my terminal and type nordvpn connect I have created a simple .sh script ...
user avatar
0 votes
0 answers
542 views

-bash: sh: command not found

I wanted to switch the shell to sh so I typed: rakinar2@hotspot:~$ sh But it says: -bash: sh: command not found How do I fix that? Note: test -e /bin/sh returns 1! EDIT: ls -l /bin/{,ba,da}sh ...
user avatar
  • 101
1 vote
0 answers
129 views

GNU make executes weird shell

The shell function in GNU make behaves weird on Ubuntu. Consider this simple Makefile: TEST1 := $(shell command -v sh) TEST2 := $(shell /bin/sh -c 'command -v sh') all: $(info TEST1 = $(TEST1))...
user avatar
1 vote
0 answers
104 views

Ubuntu live: ubiquity.desktop (alias "Install <MyDistro>") is not launched

I have created a custom distro using Cubic which comes from Ubuntu 20.04.2 LTS Desktop 64-bit. I have noticed that if I open the file manager as root and then double click on the file then it works. I ...
user avatar
1 vote
1 answer
176 views

easiest way to delete backslash from file name

I have a list of files similar to the following and I need to delete the backslash: \jskadn.txt \jsandkjasn5.txt I tried running the following command, but it doesn't work : rename " \\*.txt&...
user avatar
-2 votes
1 answer
234 views

How to write a shell script for printing the PID and The owner and the Name of the Process using the Special Variable $$ as parameter for the skript

The script shall present the command pstree -hsup $$. I have tried many different ways but I couldn't find a way to print the output like this 28348 (bash,root) 28347 (su,root) 28346 (sudo,root) 14085 ...
user avatar
0 votes
3 answers
407 views

merging tab delimited txt files based on column (which is header ) in bash?

Im having two text files which contains million records , all the records are tab delimited , how we can merge these two files based on same header(column)? file:1 LogEntryTime nameId ...
user avatar
2 votes
2 answers
228 views

Lubuntu 20.04 cannot execute .sh script from PCManFM-Qt

Lubuntu 20.04. I've created a simple .sh script to run my Java program, so content of .sh is: java -jar /path_to_my/test.jar I marked this script as executable, and when double-clicking on it in the ...
user avatar
0 votes
0 answers
164 views

How to fix "set -e -o pipefail" (CentOS script) for Ubuntu 18.04 LTS?

I'm working with a set of scripts that automate some bioinformatics (mitoVGP; https://github.com/VGP/vgp-assembly/tree/master/mitoVGP) and then the install is done as a conda environment. The problem (...
user avatar
0 votes
2 answers
118 views

Is Bash a language or a program? [closed]

I've seen it listed as a scripting language and other sources state that its just a program that runs predefined scripts in the bin whatever folder. So my question is are the bash commands on every ...
user avatar
1 vote
1 answer
109 views

How can I do command substitution in a .desktop file?

Can I do bash-like command substitution in a .desktop launcher? For example, something analogous to this: Exec=/some/prog --arg "$(zenity --entry)" By that I mean "run this command and ...
user avatar
  • 417
0 votes
0 answers
840 views

Syntax error unexpected (

I keep trying to launch this vim sh file but i keep getting the error message Syntex error: unexpected "(" #!/bin/bash openssl req -x509 -out pop1001234.cert -keyout pop1001234.key \ -...
user avatar
0 votes
1 answer
279 views

Run command one after the other from bash script

I'm trying to run some commands one after the other, but I think I'm making some mistake since only the first command is being run. I have a bash script that is like: #!/bin/bash sudo su && ...
user avatar
0 votes
0 answers
147 views

Why does $BASH_VERSION works and don't work depending on how I echo it?

I am in a sh terminal. When I do this echo $BASH_VERSION I get the version printed. However when I do this echo "`$SHELL -c 'echo $BASH_VERSION'`" I got nothing. I am not an expert on ...
user avatar
2 votes
1 answer
4k views

How to run multiple commands in multiple terminals using single shell script command

I have tried to write a shell script to run multiple commands in multiple terminals, but I can't able to run the commands, I can only able to open the multiple terminals. This is written in a shell ...
user avatar
  • 21
0 votes
0 answers
339 views

Ubuntu20: nothing happens when I try to run Anaconda install script

I have downloaded the current version of Anaconda to my Downloads folder. In Terminal I CD’d to the folder and tried bash Anaconda3-2020.07-Linux-x86_64.sh Nothing happens except that a fresh prompt ...
user avatar
0 votes
1 answer
219 views

script file command not found

I have a simple script file first.sh as shown below: #!/bin/bash echo "hello"; a = "test"; echo "$a" when I execute it, it occurs an error as written below: ./first.sh: ...
user avatar
2 votes
0 answers
5k views

sh: 0: Can't open

I am trying to run this command sh bbmap/bbduk.sh in1=fastq/Brca1Reads_ALL.1.fastq out1=fastq/Brca1Reads_ALL.1.TRIMMED.fastq ref=bbmap/resources/adapters.fa On terminal, but I keep getting: sh: 0: ...
user avatar
  • 21
0 votes
0 answers
84 views

there is another way to change multiple resolutions in linux without wait to the login

I have already make a script doing this and i put it in the start app applications, but these commands only start when you login, there is a another way to do it when the computer turn on, or ...
user avatar
0 votes
3 answers
2k views

Shell script to create a folder with files name and copy files inside

I have a list that looks like this ABC_100.0_k_1x1x1.xyz ABC_100.0_k_1x1x1.txt ABC_100.0_k_2x2x2.xyz ABC_100.0_k_2x2x2.txt ABC_100.0_k_10x10x10.xyz ABC_100.0_k_10x10x10.txt ABC_600.0_k_1x1x1.xyz ...
user avatar
0 votes
1 answer
58 views

Executing cut command on ASCII text

I have a text file written in the following way : /home/walter197/file_created.txt /home/walter197/myfile1 /home/walter197/new.txt /home/walter197/sdl.tar.gz /home/walter197/sys_info.html /home/...
user avatar
0 votes
1 answer
113 views

Make an 'if else' statement in bash which toggles key repeat

#!/bin/bash var1="r on" var2="r off" xset=$xset if [[ $(xset r on) = true ]] then $xset "$var1" else $xset "$var2" fi is the script which I tried to run to toggle the key repeat. When running ...
user avatar
  • 274
0 votes
1 answer
47 views

Trying to create a .dekstop file for an .sh

I'm trying to create a .desktop file that runs an sh file that reboots my system in Windows 10. It goes like this: [Desktop Entry] Name=Windows 10 Comment=Windows 10 Keywords=w10,windows Exec=sh /...
user avatar
  • 3
1 vote
0 answers
57 views

How to switch to HDMI audio when HDMI is plugged in?

I am using Ubuntu 18.04. Right now, I am trying to make it so that my computer switches the audio output from my headphones to my projector when it is plugged in, and vice versa. Is there a way I can ...
user avatar
0 votes
2 answers
2k views

Change the default shell to run .sh files

I have a fresh install of Ubuntu 18.04. I am running quite a few installation scripts in .sh files. I noticed that if I simply run ./my_script.sh, they will report [[: not found unless I explicitly ...
user avatar
11 votes
5 answers
20k views

My Ubuntu server has been infected by a virus kdevtmpfsi

My Ubuntu server has been infected by a virus kdevtmpfsi, I have already done serveral steps to solve this problem, like all of these: https://github.com/docker-library/redis/issues/217. But it is ...
user avatar
0 votes
1 answer
56 views

A puzzel about sh and ./

I have figured that if I want to use./to execute a script, I have to runchmod +x filefirst. But why can I execute it by using sh file without the chmod command? Doesn't sh need any executing ...
user avatar
0 votes
1 answer
370 views

command line input directory read with tab autocomplete doesn't work

I need for user to point out a directory path in command line but when trying to suggest folders with tab it gives me tab spaces function selectFolder() { local dir read -p "Enter the path of ...
user avatar
0 votes
0 answers
432 views

Is it possible to disown a background process and then later open it in another terminal window? [duplicate]

Say you have a script that takes a while to do something, but then later requires some user input e.g. something like: #!/usr/bin/python -u import time x=0 while(x<10): time.sleep(1) x+=1 ...
user avatar
0 votes
1 answer
596 views

Does anyone have a .sh script to scan recursively the current folder for 0 byte files and place them into text file?

I am looking for a simple .sh script which can scan the current folder and sub folders recursively for 0 byte files. I know this can be done in only a few lines, but I'm quite noobian on the command ...
user avatar
5 votes
2 answers
2k views

sh alternative to bash cp {file,file}

In a script, if I put #!/bin/bash at the top, this will work fine: cp directory/{foo,bar} destination However, with sh, this will give the error 'no such file or directory'. In sh, is there another ...
user avatar
  • 153
1 vote
1 answer
742 views

mkdir inside sh, won't work

I am trying to create directory using mkdir inside sh file, when I do that the directory is created, but then when trying to do something to it, I get the message "rm: cannot remove '/testFolder': No ...
user avatar
  • 11
1 vote
0 answers
70 views

bash exits immediately after adding kubectl bash completion

bash exits immediately to solve this problem I had press ALT+F2 and then set terminal to sh rather than bash. I ran sh and commented out the section which I added for kubectl bash completion: source &...
user avatar
  • 983

1
2 3 4 5