Questions tagged [shell]

The term 'shell' refers to a general class of text-based interactive command interpreters most often associated with the Unix & Linux operating systems. For questions about shell scripting, please use a more specific tag such as 'bash', 'powershell' or 'ksh'. Without a specific tag, a portable (POSIX-compliant) solution should be assumed, though using 'posix' in addition or 'sh' instead is preferable.

The term 'shell' refers to a general class of text-based command interpreters most often associated with the Unix & Linux operating systems.

Popular shells to date

  • The POSIX shell spec. (sh), a standardized shell specification derived from the Bourne shell, is not an actual shell, but the common denominator of what actual /bin/sh implementations can be expected to support across POSIX-compatible systems.
  • Almquist shell and Debian Almquist shell (dash)
  • Korn shell (ksh)
    • Public Domain Korn Shell (pdksh), not developed since 1999
    • MirBSD Korn Shell (mksh)
  • GNU Bourne again shell (bash)
  • Z Shell (zsh)
  • rc (rc)
  • C shell family

While some of these resemble each other closely, there are often subtle differences:

All of ksh93, mksh and bash are supersets of the POSIX shell, which in turn is a superset of the original Bourne Shell. By default, they support mutually incompatible extensions in syntax and behavior, but also share some extensions (beyond what POSIX offers).

The Z Shell and rc are, by default, not compatible with the POSIX shell family. Questions about the shell and code samples should be clear about the environment and the version of the shell.

Tcsh comes originally as a design improvement to the original C shell. The tcsh shell has been widely used before bash became the established shell. One major popular system implementation was the Solaris family. The shell concepts ~ (tilde for home directory), history, path expansion (globbing), directory stack and aliases all originally came from the csh.

Some view the DOS 'cmd' prompt as a minimal shell of sorts. It is also possible to install Cygwin or MSYS/MSYS2 on Windows and emulate a Unix environment with complete shell capabilities or use the Windows Subsystem for Linux ("Bash on Ubuntu on Windows").

In graphical user mode, terminal emulators are used to access the shell. Examples are xterm, GNOME Terminal, and OS X Terminal.

Related tags

Reference

91989 questions
37
votes
1 answer

How to use `jq` to obtain the keys

My json looks like this : { "20160522201409-jobsv1-1": { "vmStateDisplayName": "Ready", "servers": { "20160522201409 jobs_v1 1": { "serverStateDisplayName": "Ready", "creationDate": "2016-05-22T20:14:22.000+0000", …
sudhishkr
  • 3,318
  • 5
  • 33
  • 55
37
votes
5 answers

Is there an equivalent of tail -f on Windows?

Many times I find myself in the situation of having to follow the evolution of a log file on Windows. Is there an equivalent of the Linux tail -f command on a Windows terminal, preferably without having to install external software?…
user2233125
37
votes
2 answers

How to know if a docker container is running in privileged mode

Would like to know via bash script, if current running container was started in --privileged mode from inside the container (not from the host machine). For now I'm stuck with passing an env var with the flag but is not an ideal solution.
Leo Gallucci
  • 16,355
  • 12
  • 77
  • 110
37
votes
6 answers

Run a command shell in jenkins

I'm trying to execute a command shell in Jenkins, I'm working on Windows 7. In the console output I have this: Building in workspace C:\Program Files (x86)\Jenkins\workspace\test [test] $ sh -xe C:\Windows\TEMP\hudson6299483223982766034.sh The…
Med braim
  • 463
  • 1
  • 7
  • 12
37
votes
2 answers

What is the difference between an inline variable assignment and a regular one in Bash?

What is the difference between: prompt$ TSAN_OPTIONS="suppressions=/somewhere/file" ./myprogram and prompt$ TSAN_OPTIONS="suppressions=/somewhere/file" prompt$ ./myprogram The thread-sanitizer library gives the first case as how to get their…
user1902689
  • 1,655
  • 2
  • 22
  • 33
37
votes
4 answers

untar filename.tr.gz to directory "filename"

I would like to untar an archive e.g. "tar123.tar.gz" to directory /myunzip/tar123/" using a shell command. tar -xf tar123.tar.gz will decompress the files but in the same directory as where I'm working in. If the filename would be "tar233.tar.gz"…
Jorre
  • 17,273
  • 32
  • 100
  • 145
37
votes
2 answers

Editing Multiple files in vi with Wildcards

When using the programmers text editor vi, I'll often use a wildcard search to be lazy about the file I want to edit vi ThisIsAReallLongFi*.txt When this matches a single file it works great. However, if it matches multiple files vi does something…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
37
votes
13 answers

Changing an AIX password via script?

I am trying to change a password of a user via script. I cannot use sudo as there is a feature that requires the user to change the password again if another user changes their password. AIX is running on the system. unfortunately, chpasswd is…
Grushton94
  • 603
  • 1
  • 7
  • 17
37
votes
4 answers

How to do an unpretty print on pretty JSON file in shell >> serial string JSON >> ES _bulk?

In working with Elasticsearch on AWS EC2, I just hit an issue with bulk indexing. The ES _bulk endpoint requires the files to be basically JSON serial strings with \n terminators on each string; and what I have built using various web APIs and file…
sidgeeder
  • 419
  • 1
  • 4
  • 5
37
votes
10 answers

idioms for returning multiple values in shell scripting

Are there any idioms for returning multiple values from a bash function within a script? http://tldp.org/LDP/abs/html/assortedtips.html describes how to echo multiple values and process the results (e.g., example 35-17), but that gets tricky if some…
Wang
  • 3,247
  • 1
  • 21
  • 33
37
votes
15 answers

Run C or C++ file as a script

So this is probably a long shot, but is there any way to run a C or C++ file as a script? I tried: #!/usr/bin/gcc main.c -o main; ./main int main(){ return 0; } But it says: ./main.c:1:2: error: invalid preprocessing directive #!
Brendan Long
  • 53,280
  • 21
  • 146
  • 188
37
votes
7 answers

How to grep the last occurrence of a line pattern

I have a file with contents x a x b x c I want to grep the last occurrence, x c when I try sed -n "/x/,/b/p" file it lists all the lines, beginning x to c.
user3702858
  • 381
  • 1
  • 3
  • 3
37
votes
1 answer

Brace expansion with range in fish shell

In bash, I can do the following $ echo bunny{1..6} bunny1 bunny2 bunny3 bunny4 bunny5 bunny6 Is there a way to achieve the same result in fish?
workflow
  • 2,536
  • 2
  • 14
  • 11
37
votes
1 answer

Linux Shell Script - String Comparison with wildcards

I am trying to see if a string is part of another string in shell script (#!bin/sh). The code i have now is: #!/bin/sh #Test scriptje to test string comparison! testFoo () { t1=$1 t2=$2 echo "t1: $t1 t2: $t2" if […
AlexT82
  • 1,114
  • 1
  • 7
  • 12
37
votes
2 answers

Vagrant provisioning shell vs puppet vs chef

I have the following setup: Many different projects which are separate git repositories, but all have mostly the same server configuration Each project in turn depends on many other projects and we use the composer dependency manager to get them…
mpaepper
  • 3,952
  • 3
  • 21
  • 28
1 2 3
99
100