sh stands for a shell. It is also often used as extension for a shell script.
Questions tagged [sh]
210 questions
439
votes
5 answers
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 emacs test_queue.cpp
Bobby
- 4,501
- 3
- 15
- 6
83
votes
1 answer
Is redirection with `>>` equivalent to `>` when target file doesn't yet exist?
Consider a shell like Bash or sh. The basic difference between > and >> manifests itself in a case when the target file exists:
> truncates the file to zero size, then writes;
>> doesn't truncate, it writes (appends) to the end of the file.
If the…
Kamil Maciorowski
- 69,815
- 22
- 136
- 202
60
votes
8 answers
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 PS1="$(whoami)@$(hostname):$(pwd)"
in /etc/profile.
But as obvious…
Bleamer
- 721
- 1
- 5
- 9
50
votes
2 answers
What exactly is the sh command?
I can't figure out what the sh command is?
http://unixhelp.ed.ac.uk/CGI/man-cgi?sh
Does it execute a file?
like in tomcat:
sh /usr/local/tomcat/bin/shutdown.sh
Sorry, just confused.
user3183
- 3,327
- 15
- 60
- 70
47
votes
6 answers
How do I start in bash when ssh'ing into my server?
I have a hosted Debian server. When I log in via ssh, I'm greeted with a sh environment. How do I change it so I start in a bash environment?
bbbgscott
45
votes
4 answers
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
$
Hieu Nguyen
- 925
- 3
- 8
- 14
44
votes
3 answers
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:
echo 'foo' \
| sed 's/d/a/' \
| sed 's/e/b/' \
| sed 's/f/c/' \
> myfile
(sed is just an example, actually it is a mix of…
Nicolas Raoul
- 10,711
- 18
- 64
- 102
37
votes
2 answers
What is wrong with “echo $(stuff)” or “echo `stuff`”?
I used one of the following
echo $(stuff)
echo `stuff`
(where stuff is e.g. pwd or date or something more complicated).
Then I was told this syntax is wrong, bad practice, non-elegant, excessive, redundant, overly complicated, cargo cult…
Kamil Maciorowski
- 69,815
- 22
- 136
- 202
32
votes
4 answers
What does % do in Linux shell strings?
In Linux shell, what does % do, as in:
for file in *.png.jpg; do
mv "$file" "${file%.png.jpg}.jpg"
done
Nissim Nanach
- 640
- 6
- 13
24
votes
3 answers
How is install -c different from cp
What is the difference between install -c and cp? Most installations tend to use install -c, but from the man page it doesn't sound like it does anything different than cp (except maybe the ability to also set permissions). When should I use install…
sligocki
- 849
- 1
- 9
- 11
22
votes
5 answers
/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 second setting"
ANOTHER_SETTING="This is another…
Majenko
- 32,128
- 4
- 61
- 81
20
votes
2 answers
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 environment variables from .profile when it gets updated,…
hugomg
- 659
- 3
- 6
- 15
20
votes
9 answers
How to find length of string in shell
I need to calculate the length of a string using pure sh shell only. What is happening is that /bin/sh is actually a soft link to bash or another shell. Hence ${#STRING} gives the length of string as it is advance bash feature.
Can someone tell me…
Niraj Nandane
- 389
- 1
- 3
- 12
17
votes
4 answers
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 systems). If I run zsh from within sh after running sudo…
Jules
- 698
- 4
- 10
- 26
16
votes
1 answer
Redirect stdout/stderr of a background job from console to a log file?
I just run a job (assume foo.sh).
./foo.sh
[Press Ctrl-Z to stop]
bg # enter background
And it generate output to stdout and stderr.
Is there any method to redirect to stdout and stderr to other file instead of current screen?
Daniel YC Lin
- 1,015
- 3
- 13
- 26