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
0answers
43 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
36 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
22 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
33 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
29 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
23 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
0answers
7 views

Using debugfs and only show ctrtime on terminal

Good morning. I am having an issue with my bash script. I want to extract a file creation date, and to do so I'm using debugfs, and I already acessed the crtime line, but the header line "debugfs ...
0
votes
2answers
87 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 ...
6
votes
1answer
2k 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
33 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
45 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
46 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
76 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
796 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
63 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
52 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
88 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/...
0
votes
0answers
15 views

Installing by shell script file [duplicate]

I am new to ubuntu 18.04. I have downloaded a. tgz file and extracted on desktop. There is a rdragon file( file type:shell scriot(application/x-shellscriot). I used the command chmod and chmod 777 but ...
0
votes
1answer
234 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 ?...
3
votes
1answer
456 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
76 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
63 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 ...
5
votes
1answer
751 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
93 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
91 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
118 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
750 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
35 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
190 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
46 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
54 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 ...
16
votes
2answers
2k 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
1k 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-...
2
votes
1answer
425 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
27 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
48 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
71 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
40 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....
0
votes
0answers
51 views

Making sh script executable [duplicate]

In Xubuntu I have marked the .sh file as executable, but it still opens in mousepad, and there is no "execute" button on right click, just "open with", I can execute the script only by dragging it in ...
1
vote
1answer
469 views

Running a specific script with double click [duplicate]

I want to create a script that automatically downloads a zip from the internet like the following sh script named test.sh : #!/usr/bin/env bash curl -o csvs.zip https://randomCloudCsv/download But ...
-1
votes
1answer
148 views

Bash files don't run and when running in terminal text editor runs instead (Ubuntu 19) [closed]

I am having a BIG issue with a .sh file. When I try to run it in the terminal, I end up opening a text editor instead (the text editor that runs within the terminal). I tried changing the preferences, ...
0
votes
1answer
1k views

Shell script error to check if file exists

#! /bin/bash echo -e "Enter the name of the file : \c" read file_name if [ -e $filename ] then echo "$file_name is found" else echo "$file_name is not found" fi i'm running the above to check the ...
-2
votes
1answer
1k views

Help trying to execute a sh on background

Hi i have a problem trying to execute a sh script on background /home/user/server-data/run.sh +exec server.cfg i want execute that script on background but it dosen't work even if i use the & on ...
0
votes
1answer
74 views

The correct place to put scripts for every logged user including ROOT

I'm looking for the correct place to hold scripts to run for all users including the root user. I know that adding content to the /etc/profile file or creating scripts into the /etc/profile.d/ folder ...
3
votes
1answer
562 views

How to display a value with zenity?

I'm trying to calculate Euler's numb. but I'm having problems trying to display the result. This is what I have: #Using a switch an case "Euler's Number") szAnswer=$(zenity --info --text "Enter a ...
1
vote
0answers
78 views

How to set .sh file to execute on startup on Ubuntu in VirtualBox?

VirutalBox Ubuntu sets default resolution on every launch. Found a comment in a topic here on how to create a .sh file, said also to add it in Startup Applications. But on reboot the .sh file didn't ...
0
votes
1answer
34 views

Piping two server calls

I am trying to pipe two server runs (one using yarn, one using phoenix/elixir). My code: sudo service elasticsearch start; source env/local.env; iex -S mix phx.server| cd front-end; yarn start:dev-ng;...
5
votes
2answers
5k views

Shell script can be run only with sh command

I have a small sh script that I use to backup to a remote server. It worked on Ubuntu 16.04 for years, but now on 18.04 it fails. At first I thought it was a problem with anacron, but now I think it ...
0
votes
1answer
204 views

Creating a file but with an specific name

So I have a project which needs to create a list of numbers which then will be sum all together and more, but right now, one of my problems is that that I need to give the user the option to decide ...