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)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 29678

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 http://shellcheck.net before posting here.

15
votes
Expect can do that. From the Expect website: Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial. E …
answered May 20 '15 by Christopher
1
vote
The $? contains the value of the exit code of the very last command executed. You can stack up exit codes in a case statement as well. #!/usr/bin/env bash awk -v CONFIG_SOURCE=Testfile1.txt -f test. …
answered May 20 '14 by Christopher
3
votes
The case-insensitive and case-preserving behavior is an old choice made by Apple, and it seems to me that the shell is just echoing whatever you type. (Try LS /BIN/CP.) This behavior is eliminated …
answered Aug 17 '17 by Christopher
9
votes
the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells. You can read more on IEEE Std 1003.1, Shell Command …
answered May 21 '15 by Christopher
1
vote
You meant to write from shh to shh2, right? To change the string, alias shh, to the string, alias shh2, just edit the Korn Shell RC file and re-source it. You could do this with any text editor, or …
answered Jul 22 '15 by Christopher
8
votes
context, the usage of [[ and ]] is specific to BASH. (Tangentially, [[ and ]] also work with zsh and the Korn shell.) See BashFAQ/031. Portable scripts should be written with [ and ] which work in all POSIX shells. …
answered Sep 7 '17 by Christopher
4
votes
in /etc/passwd. It is also the same as the $HOME environment variable. The expansion from ~ to the home directory is done by the shell. …
answered Jan 18 '13 by Christopher
1
vote
From llua's suggestion, we can work a little more with history. Append a line to the system-wide BASH RC file, perhaps /etc/bash.bashrc. export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$( …
answered Jan 21 '13 by Christopher
4
votes
Can commands be written to a logfile before they were executed in any shells? Given the other questions, I take it that another way to think about the question might be "What can I do to make sur …
answered May 28 '15 by Christopher
1
vote
The following illustrates one way to accomplish the goal with a script. #!/bin/bash # Get a list of users, filtering out service accounts, root, daemon, and nobody... # users=$(dscl . list /Users | …
answered Feb 15 by Christopher
3
votes
Here's a simple way. Below are the contents of a script named script.sh in ~/bin/. #!/usr/bin/env bash if (file "$1" | grep "RaspberryPi"); then echo "rm $1" # <- safety first: just echo, no dele …
answered Dec 29 '16 by Christopher