Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*"
Favorites infavorites:mine
Status closed:yes
Types is:question
Exclude -[tag]
For more details on advanced search visit our help page
Results tagged with Search options answers only user 73093

The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in before posting here.

another more powerful shell, you can also use here strings: val=$(wc -c <<<"$line") <<< performs expansion on the string "$line" and then provides it as the standard input of wc -c. In this …
answered Aug 11 '14 by Michael Homer
Tilde expansion is defined by POSIX as: A "tilde-prefix" consists of an unquoted <tilde> character at the beginning of a word, followed by all of the characters preceding the first unquoted <slash …
answered Aug 24 '14 by Michael Homer
Use "${*:2}" instead of "${@:2}" $@, and ${x[@]}, and their variants, expand to one "word" per element in the array when quoted. $* (and ${x[*]}) expand to a single word with all the elements jo …
answered Dec 24 '15 by Michael Homer
While you can do this with a loop and stat if you really want, this is something that find is good at and can do in a single line. You can create a special timestamp file each time your script runs an …
answered Aug 10 '14 by Michael Homer
will a script have different behaviour depending on what type of shell is executing it. In the sense that bash and ksh are likely to behave differently, yes. Commonly, that … likely to hit one of the many differences between the languages provided by different shells. Will a script behave differently depending on your value of SHELL? Only if the script either invokes $SHELL
answered Oct 20 '14 by Michael Homer
It will be easiest just to fix the array after the fact. After done, adding unset 'EXT_OPTS[-1]' unset 'EXT_OPTS[-1]' will remove the last two values (-o and -iname), and then you can add others if …
answered Feb 8 by Michael Homer
ls -t on its own will list all files in the current directory with that sorting, without ever needing to list them on the command line at all. If you need the recursion behaviour of find, or to do so …
answered Aug 11 '14 by Michael Homer
"sh compatible" refers to POSIX sh, the basic shell that is required to exist on all compatible systems. A sh-compatible script should work on any POSIX-compatible machine. The reason it's necessary … that don't use bash as /bin/sh, including some commercial Unices forever, and Debian and derivatives recently. In particular there's been a trend to use dash, the Debian Almquish Shell, as the default …
answered Jul 20 '14 by Michael Homer
document is not subject to expansion by the shell, so you can write a $ in the body without dash eating it. Your script can include anything other than EOF (or your word of choice) at the start of a … the shell as standard input (but I don't believe it's required to). Shells generally read standard input line-by-line (but they are not required to behave in that way). If your implementations do …
answered Mar 23 '15 by Michael Homer
As you suspect, the exact behaviour is shell-dependent, but a baseline level of functionality is specified by POSIX. Command search and execution for the standard shell command language (which most … environment variable as described in XBD Environment Variables and If the search is successful: [...] the shell executes the utility in a separate utility environment with actions equivalent …
answered Dec 27 '16 by Michael Homer
$* is all the parameters to the script or function, split into separate arguments on whitespace. If you have a function: foo() { for x in $* do echo $x done } then running foo …
answered Jul 8 '14 by Michael Homer
part of the WORD token being constructed. This is because rule 5 ("If the current character is an unquoted $ or `, the shell shall identify the start of any candidates for parameter expansion, command … character of a variable name A <left-curly-bracket> ( '{' ) A <left-parenthesis> the result is unspecified. "Unspecified" is a particular term here meaning that A conforming shell can …
answered Jan 4 by Michael Homer
that the "variable" is unavailable because you can't modify its value persistently. Any variable assignments you make within a subshell are not available to the parent shell afterwards, whether that's …
answered Sep 12 '16 by Michael Homer
output of grep and then run sh long_myfile_name. (Change sh to bash if your script depends on Bash-specific features, or some other shell) You can also run sh *myfile* with essentially the same effect in …
answered Jun 23 '14 by Michael Homer
. So the answers to your questions are: Use one of the approaches above. You do need to use another command to bootstrap you into the library, or a piece of software that hooks into your shell. All in all, you'll almost certainly be better off doing this any other way. …
answered Apr 8 '18 by Michael Homer

15 30 50 per page