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
2
votes
2answers
38 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 ...
0
votes
0answers
54 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 (...
0
votes
2answers
101 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 ...
1
vote
1answer
62 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 ...
0
votes
0answers
237 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 \ -...
0
votes
1answer
74 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 && ...
0
votes
0answers
30 views

Assign shortcut key ALT+TAB to run a script in Kubuntu (from Ubunto)

I've written a script (rofi.sh) to run rofi -show window (apt install rofi) The test of the script (rofi.sh) works as expected. I want run this script, just by pressing Alt+TAB I tried to add it in ...
0
votes
0answers
47 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 ...
0
votes
1answer
2k 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 ...
0
votes
0answers
201 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 ...
0
votes
1answer
40 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: ...
0
votes
0answers
1k 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: ...
0
votes
0answers
52 views

Ubuntu 19.10 is not starting, [FAILED] messages on boot

I was using Firefox and terminal; there I was converting a python file to APK with buildozer after I found that .sh files are not available so I ran several commands and my laptop hung. I was not able ...
0
votes
0answers
52 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 ...
0
votes
3answers
608 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 ...
0
votes
1answer
39 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/...
0
votes
1answer
75 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 ...
0
votes
1answer
40 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 /...
1
vote
0answers
43 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 ...
0
votes
2answers
793 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 ...
7
votes
4answers
13k 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 ...
0
votes
1answer
40 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 ...
0
votes
1answer
173 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 ...
0
votes
0answers
203 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 ...
0
votes
1answer
419 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 ...
5
votes
2answers
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 ...
1
vote
1answer
294 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 ...
1
vote
0answers
62 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 &...
0
votes
1answer
184 views

script not working in cron but works from command line

#!/bin/sh # Script to start multi-user session of MFG/PRO # tokens: # &DLC = Progress Directory # &CLIENT-DB-CONNECT = command line to connect to each db in dbset stty intr '^c' DLC=/apps/...
1
vote
1answer
839 views

“-sh: 2: logout: not found” - message when trying to logout from the server

When I connect to my server: ssh user@ip.address I login with a password, and then do: logout I get this message "-sh: 2: logout: not found". Why can't I log out ? What does this message mean ?...
4
votes
2answers
1k views

CLion doesn't pick up environment variables sourced in bashrc

Long Story (This is X) TLDR / The Problem (This is Y) Now, if running sh /opt/clion/bin/clion.sh from the Ubuntu terminal, CLion does pick up the environment variables sourced in the ~/.bashrc file, ...
1
vote
1answer
118 views

How can I test if there are entries in the terminal command history in bash?

I'm still quite new to bash scripting and I need a very simple script that, if there is command history, displays it, and, if there isn't, informs the user that there is no command history. What I ...
0
votes
1answer
74 views

Traverse through all folders and renaming all files inside folder sequentially 1.*, 2.*, 3.*

This does not work... I am still rather bad with sh scripts. for imageFolder in *; do [ -d $imageFolder ] && cd "$imageFolder" && for file in *.* do ...
6
votes
1answer
5k views

Why doesn't auto complete work in my shell?

I am not so into Linux and I have the following doubts: a client provided me an Ubuntu 18.04.3 LTS virtual machine which I access via SSH. (I am using MobaxTerm as SSH client but it should not be the ...
3
votes
1answer
233 views

Ubuntu is asking for sudo password on startup

Since some weeks ago, my Ubuntu 18.04 is asking for root password, saying "sudo password needed to launch /bin/sh". I skip this prompt but I wonder why this is happening and how can I diseble it? It'...
1
vote
2answers
302 views

Show locations of duplicate lines across multiple files

I have two files: #a.txt 11 22 33 44 55 11 And # b.txt 55 66 77 88 99 11 I do this command to print duplicate lines across two files: sort *.txt | uniq -D And it outputs: 11 11 11 55 55 I ...
3
votes
3answers
158 views

How do I assign the Output of a command as a Value of a variable?

I have a simple bash script like below : #!/bin/bash hname='hostname' echo Hello, my server name is $hname But the output is not as I expected. It is as below : Hello, my server name is ...
1
vote
1answer
2k views

Diagnose 'sh: 1: Bad substitution' from /bin/sh -exc

I've been trying to compile some ocaml packages and keep running into some errors of the form sh: 1: Bad substitution (exit code 2), eg. /bin/sh -exc echo | m4 /bin/sh: 1: Bad substitution But, /...
1
vote
0answers
42 views

Autorun script while plugging in a USB device on a USB-media blocked PC

I have about 50 PCs with Ubuntu versions ranging from 12 to 18. All is USB media blocked. I want to copy a folder from my USB to a standard user account. Every time I have to manually acquire root ...
7
votes
2answers
215 views

What does this if-then statement mean?

Playing around in my system, I stumbled upon ~$ echo $XDG_DATA_DIRS /usr/share/ubuntustudio:/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share Asking myself why /usr/...
1
vote
1answer
95 views

Is it possible to switch shells without getting dumped into the old shell by exit?

For example, let's say I have bash, sh, fish, zsh, pwsh or more installed. If I start bash, switching into sh leads to the following: user@device:/folder/directory$ sh $ exit user@device:/folder/...
2
votes
1answer
61 views

I need to run xrandr -o normal at startup and keep getting Bad Interpretation error

All I need to run xrandr -o normal at startup and keep getting Bad Interpretation error - No such file or directory exists. This is the script I have: #!bin/bash xrandr -o normal I've checked the ...
-1
votes
1answer
39 views

Create an array in data file while the value in a specifc column is constant

I have the follow data set: M1 1 1233 M2 1 3212 M3 1 55323 M4 1 4444233 M5 1 23444 M6 1 555333 M7 1 55567 M8 2 22224 M9 2 55566 M10 2 4567 M11 3 44242 M12 3 234234 ...
14
votes
2answers
3k views

Mistakenly modified `/bin/sh'

I had this script: spd-say "Hello, don't forget the trash bin." So it reminded me of what I supposed to do, and I moved it to /usr/local/bin/ and the command trash pronounced the argument,then I set ...
0
votes
4answers
2k views

compare two lines and print unmatched words from two files

I have two files,Lets say file1 and file2 file1 has "eipassoc-03cd9117d7188d2 eipasoc-47367a3f eipasoc-bbbddc3 eipassoc-10bbfb6" each one is space delimited file2 has "eipasoc-...
3
votes
1answer
773 views

Continue command on a new line

To improve the readability of my code, I want to go to a new line in the code but I do not want the compiler to treat is as a different line of command. How do I do this? python file_a.py file_b.py ...
0
votes
0answers
29 views

How to run script concatenating outputs to file and running in background?

I have the following script: #!/usr/bin/env sh set -x ( echo "Running command ls -la" && \ cd folder/path && \ ls -la ) $>> some_file 2>&1 & Pretty much ...
0
votes
1answer
57 views

How to automate screen multiplexer to automatically start on a path and execute a file

I want to automatically: screen -S Test cd /home/dapkkins/Servers/Bungee sh start.sh ^Ad My sh file to run my server through ssh
1
vote
0answers
217 views

udev script not running, works in test

I'm trying to make a script run automatically when I dock or undock my laptop. I have this simple test script I want to run: $ cat /usr/local/bin/undock.sh #!/bin/sh /usr/bin/touch /tmp/testFile....
-1
votes
1answer
99 views

Moving certain characters from one file to another

Let's say we have text file File1.txt that contains digits and alphabetic characters: 1 2 3 a 4 5 9 2 3 b 1 2 a l a i o l a 9 2 c Do you know how to write a bash script that takes digits from File1....