sh stands for a shell. It is alo often used as extenstion for a shell script.

learn more… | top users | synonyms

23
votes
3answers
61k views

Which command in the Linux/UNIX sh shell returns my current directory?

Using the sh shell (not bash), which command in Linux/UNIX prints out my current directory? $ *showmewhereiam* /sys/kernel/debug $
0
votes
1answer
39 views

How to transparently substitute sha1sum for shasum in sh shell?

I have a test that needs to run on multiple platforms. On all other platforms, the test uses sha1sum, but on my Mac OSX El Capitan, there is no such program installed, but shasum works fine as a ...
0
votes
0answers
21 views

Startup script unexpected results

I'm experimenting with a small script to setup my webserver on Vultr. This is a "Startup script" that is used by Vultr on the background after deploying a new machine for me. If I run manually with ...
0
votes
0answers
44 views

sh command not found on Windows 10

I'm trying to install devkit using the command npm install -g devkit. It makes a loading bar which goes on for a few minutes then gives an error, firstly saying that the sh command can't be found, ...
3
votes
0answers
43 views

Redirecting display linux

from a sh shell, I am running a script calling a Software that requires opening a Gui. It ends up with a flashing window each time the call is run. I tried to unset the DISPLAY environment variable ...
0
votes
0answers
9 views

How to make ConEmu execute .sh in the same window with Git for Windows?

I'm using ConEmu on Windows with Git for Windows installed. When I try to execute an .sh script, the software starts an instance of Windows' default console and executes the script there. How can I ...
-1
votes
2answers
38 views

what does “exec 5>>foobar.txt” do?

What does the shell command exec 5>>foobar.txt do? I can't google it for obvious reasons, and otherwise not sure where to start looking.
0
votes
1answer
23 views

Piping stdout from a command to stdin of two commands in sh

tee [using >()] command is not working because it is not supported in sh (bourne shell). What I am trying to achieve is sending the output of "ifconfig -a" to two different commands. This is my ...
0
votes
0answers
10 views

XWorking with .sh Files in XTerm

.I am trying to install my VPN software on my Lubuntu 15.10 and I am using Xterm to follow through a few commands. First I run wget https://www.privateinternetaccess.com/installer/install_ubuntu.sh ...
0
votes
0answers
21 views

bash “vi mode” search command line (not history buffer)

When working in bash - if I am in "vi" mode, I can use ? or / to "search". However, this appears to search the history buffer. If I am working with a (very) long command line, I would like to be able ...
0
votes
1answer
24 views

Duration time between cycles in a log file

My apologies if this is too basic, but I have a log with this kind of information: Mai 5 12:34:00 xoengine XO[1287]: [Xo|xoengineMain.cpp:122|0xb88ec60] starting xoengine 4.0.1.2 (x86) from ...
2
votes
1answer
82 views

How is WinSCP able to provide a sudo user for executing scp?

The tool WinSCP is able to perform a sudo on the remote machine to perform the scp as the sudo user. That leads me to think that this must be possible with the command-line version of scp as well. ...
178
votes
5answers
190k views

How can I resume a stopped job in Linux?

How can I resume a stopped job in Linux? I was using emacs and accidentally hit ctrl-z which blasted me back to the console. I can see it when I type 'jobs' [*****]$ jobs [1]+ Stopped ...
0
votes
1answer
46 views

Displaying unicode emoji in filenames on Ubuntu

I'd like to use emoji in filenames and access them on the command line, but I can't seem to get it to work with ls. Weird thing is, if I pipe into just about any other program, the emoji are correctly ...
0
votes
1answer
31 views

Debugging env vars from ssh

I'm writing a script and an application for an embedded board with linux - no X, only console. The only way to reach the target is via ssh, I don't have a monitor connected. The script should export ...
0
votes
1answer
27 views

Autostarting a script at boot doesn't recognize the function “function”

I'm trying to get a script containing a function to run just after root autologin on TinyCore 5.3. The script works fine if I launch it from the prompt after login like this ./script.sh But when I add ...
12
votes
3answers
5k views

Comments in a multi-line bash command

This single-command BASH script file is difficult to understand, so I want to write a comment for each of the actions: grep -R "%" values* \ | sed -e "s/%/\n%/" \ | grep "%" \ | grep -v " % " \ | ...
18
votes
4answers
84k views

How to display current path in command prompt in linux's sh (not bash)?

I would like to display current path in sh prompt (not bash shell), which currently just shows "#", I tried with introducing this env PS1="$(whoami)@$(hostname):$(pwd)" and set ...
0
votes
0answers
20 views

pgpass does not execute

So i have a backup1.sh script in /home/user/ #!/bin/sh tar -czf /home/ruud/backup1.tgz /usr/lib/python2.7/dist-packages/openerp pg_dump -U dbadmin -h 127.0.0.1 123telcom -f /home/ruud/dbbackup.sql ...
6
votes
4answers
3k views

/bin/sh source from stdin (from other program) not file

Kind of a tricky one to name this... Basically I have a program which when run prints on STDOUT a set of shell variables: $ ./settings SETTING_ONE="this is setting one" SETTING_TWO="This is the ...
0
votes
1answer
138 views

How to run script menu after new terminal window exits

I have a script that asks the user for input for options. When selecting the option I have it so it runs a new terminal and executes another script for the specified option. I still want the menu ...
0
votes
2answers
57 views

Whitespace treatment in OS X vs Linux in Bash

I am trying to run a very simple script on a few different platforms: #!/bin/bash STRING="this is a test" echo $STRING , and I cannot tell why on Mavericks and Yosemite I get the output: ...
0
votes
1answer
5k views

Linux sh script throws “#!/bin/sh: not found”

i have a script #!/bin/sh # Automatically remove a torrent and delete its data after a specified period of # time (in seconds). TARGET=/var/www/transmission/completed USER=name PASS=pass ...
0
votes
1answer
58 views

Double exit in gzexe

I have seen in gzexe (source) they use the following pattern used in a lot of places all over the file: (exit $res); exit $res What purpose does the exit inside the sub-shell? Doesn't seem to do ...
0
votes
1answer
569 views

Can't install android studio on linux mint 17.2

I have downloaded android studio for linux , after unzipping the zip file I went to specif location which is android-studion/bin and open terminal there then i run ./studio.sh command , when I run ...
0
votes
1answer
216 views

Why does sh not find files in my path that do exist?

When I type this in sh it outputs : $ $PATH sh: 12: /bin:/usr/bin: not found But, I do have a /usr/bin folder, and it's fuuuuull of stuff. Same thing with zsh: ▶ $PATH zsh: no such file or ...
0
votes
1answer
4k views

Running sh.exe in windows cmd.exe: command not found

For some reason I need to run a (hopefully simple) sh file under Windows and be able to do so from another application. I can do that using cygwin, but for various reasons I need this operation to be ...
7
votes
4answers
14k views

How do I change my default shell to bash if I don't have access to chsh nor /etc/passwd?

I'm working on a university remote Linux account, and the default shell is sadly csh without tab completion. How can I change my account's default shell to bash? chsh is not available.
7
votes
8answers
815 views

Remove linux file named with set of shell responsive characters

I've created a file named \;:$"\' to test a software of mine. I ended up with an error, because I cannot delete the file property. I'm trying to find a precise character combination to remove it via ...
0
votes
1answer
29 views

How can I append text in the middle of a pipeline?

With cat its possible to append a file to the data passing through a pipeline: foo | cat - somefile.txt | bar Is there a command that lets me append text without using an intermediate file? foo | ...
4
votes
4answers
6k views

Change the sudo su shell

Whenever I run sudo su from my normal zsh (which uses the oh-my-zsh framework), I'm forced to use the old Bourne shell (sh) by default (obviously; this is standard behaviour on most *nix-like ...
0
votes
2answers
162 views

sh -c in background

Original version: How to run sudo sh -c "command" in back ground In a terminal sudo sh -c "command" & starts in background but as soon as I press enter, the process exits [test@localhost ...
1
vote
2answers
269 views

Is there a way to have sh/bash/zsh “case” use a variable for a test value?

I'd like to have something like the following: #!/bin/sh # ... other stuff ... # some relatively static possibilities (srsp): srsp='this|or|that|the|other' # more other stuff case $something in ...
0
votes
1answer
120 views

How do I save a string of numbers from an ongoing command to a list in a shell script?

I am trying to make a shell script for recording macros via recording the individual keycodes of each button press. The command for it looks like this: xev | grep -A2 --line-buffered '^Key*' | sed ...
0
votes
1answer
92 views

How to extract a substring and add it to original string with sed?

I am trying to write an sh script witch receives a string as input, extracts a particular substring and adds it after an specified expression to the input string. I tried a lot with sed -i'N ... but ...
4
votes
1answer
148 views

How do I prepend a string to program output without waiting for the whole line?

I have a script that runs a command on a remote server using SSH. I want to prepend the string Remote: to every line of the output, but I don't want each line to be delayed until the whole line is ...
0
votes
0answers
22 views

Configure a default shell script environment

Is there any way to change the default environment when running sh -c <command>? It appears that .cshrc is not called when running command with a -c flag.
0
votes
3answers
7k views

Make .sh file executable

I have a .sh file which is not becoming an executable. I tried doing it in the properties but as soon I ticked the checkbox, the tick vanished in a second. I then tried sudo chmod +x filename.sh ...
0
votes
1answer
49 views

cd to newest directory

Not strictly bash, but rather Bourne shell if possible. How can I programmatically cd to the newest directory? I want to install the latest package of whatever software, which is located in the newest ...
-2
votes
1answer
74 views

Bash executing command

Can anyone please give me the list generated by this : -{ for i in {1..100}; do lynx -dump -nonumbers -listonly [http]://www.dailymotion.com/user/MTDCafe/$i ...
0
votes
1answer
192 views

Bash scripts executed together don't kill background processes

I have a number of shell scripts that work very similarly to this question. Each script fires up a few background tasks, remembers their PIDs with $!, does some testing, and then kills the background ...
1
vote
1answer
39 views

Evaluating false in bash with multiple commands without a subshell

Bash evaluates the logical operators such that && always takes precedence. So for example: false || echo 1 && echo 2 1 2 and true || echo 1 && echo 2 2 Ok. So lets say I ...
1
vote
3answers
101 views

Most efficient log “echo date”?

My coworkers write scripts with lines like this: echo "nightly $MACHINE restart begins at" `date` Which outputs something like this: nightly whitestar restart begins at Mon Oct 13 22:05:01 EDT ...
1
vote
1answer
841 views

Is there a way to “source” a sh script from the fish shell?

I like to put many of my environment variable definitions in the .profile script. If I am using a POSIX-compatible interactive shell like bash, I can use the source command to re-export the ...
2
votes
1answer
104 views

Pipe standard error to file and keep it on standard error?

I have a script (fragment) for which I'm logging output and standard error: #!/bin/sh #... { date "+%Y-%m-%d %T" cd $workdir ls -ltr validfile badfile #example command that provides stdout, ...
1
vote
1answer
908 views

Background Jobs from cron

I am running a cron on every two minutes. From the cron I am running other shell scripts in background with "&". After cron exits spawned shell script process still runs, this is desired behavior. ...
1
vote
1answer
174 views

Bash - list files within date range

So far I've been basing my efforts around this blog and have come up with: startdate=”201407010000? enddate=”201408010000? touch -t $startdate ./startdatefiles touch -t $enddate ./enddatefiles find ...
0
votes
1answer
2k views

unable to execute: Too many levels of symbolic links

By mistake, I executed these commands : sudo ln -sf bash /bin/sh sudo ln -sf bash /bin/bash When I rebooted the Linux server in recovery mode I got this message: init : Failed to spawn ...
0
votes
1answer
29 views

why following script is failing?

#!/bin/sh declare -a LIST= ('a' 'b' 'c' ) is failing on Ubuntu on which /bin/sh is softlink to /bin/dash How can I declare list which will be supportable on all kind of shell ?
1
vote
3answers
1k views

How to find length of string in shell

i need to calculate it using pure sh shell only. What happening is /bin/sh is actually a soft link to bash or other shell.Hence ${#STRING} gives length of string as it is advance bash feature. Can ...