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 10043

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.

-1
votes
3answers
I'm trying to have a small function that I then call. To keep it simple I just want to validate that 12 is divisible by 2,3 and 4 The code is: divisible_by () { under_test=12 from=2 to=4 di …
asked Jan 4 '15 by Michael Durrant
2
votes
2answers
I tried using this: $ if [$a == 1] then { echo 'yes'; } fi; but I get an error: -bash: syntax error near unexpected token `}' What is the correct format? I tried several with no luck.
asked Sep 30 '13 by Michael Durrant
38
votes
2answers
I have the following working code: largest_prime=1 for number_under_test in {1..100} do is_prime=true factors='' for ((divider = 2; divider < number_under_test-1; divider++)); do remainde …
asked Jan 3 '15 by Michael Durrant
1
vote
1answer
I'd like to have named parameters for my functions. I seem to only be able to use GETOPTS for the main function called from the command line. If I have multiple functions within one file is there an …
asked Mar 9 '15 by Michael Durrant
0
votes
I can't redefine ls itself but you can use this function for an 'ls2': ls2 () { num_of_files=`ls | grep "\/$" | wc -l` if [ "$num_of_files" -gt "10" ]; then ls | less else ls -l fi …
answered Mar 25 '16 by Michael Durrant
20
votes
4answers
When should I use -eq vs = vs == e.g. [[ $num -eq 0 ]] [[ $num = 'zzz' ]] I've observed a pattern of using -eq (and -ne, etc.) for numbers and = for strings. Is there a reason for this and whe …
asked Nov 16 '14 by Michael Durrant
1
vote
1answer
if I have $ x='This is a String' $ export x $ xterm & [3] 14089 The child process doesn't seem to respond to $echo $x $ Update: The FIRST time I export the variable it seems to span a process …
asked Aug 7 '13 by Michael Durrant
1
vote
One option I like is to create aliases that have the same or similar options, e.g. alias rmi='rm -i' alias rmiv='rm -iv' alias rmv='rm -v' alias cpr='cp -r' alias cprv='cp -rv' This way you have a …
answered Aug 3 '14 by Michael Durrant
3
votes
One option is to have it run as a bash script, just like your local environment that you are comparing to For the script to run under under bash, put this as the FIRST line of the program: #!/usr/bi …
answered May 30 '15 by Michael Durrant
6
votes
;/@/{h;s/test/next/g;x;G}? /@/ search for an `@` sign {} for the lines where that is true do this 'block' of code h put the pattern match in the hold space s/ substitute test for next everyw …
answered Nov 13 '13 by Michael Durrant
5
votes
vi-copy 'y' copy-selection Finally (to close the loop), here's my .vimrc settings themselves that I like having to make the shell easier to use: " mdd specific stuff --- start set hlsearch set … () Finally I make a few changes to my .bashrc file For example with shopt -s autocd when I type a directory name (that exists) my shell cd's into that directory immediately. Nifty! So here's my …
answered Nov 26 '12 by Michael Durrant
0
votes
3answers
For example I want to change "'this text'" "that text" 'other_text' into 'this text' "that text" 'other_text' I tried sed -e 's/^"\'/"/g' but my quoting must be off. Ubuntu.
asked Sep 17 '15 by Michael Durrant
36
votes
2answers
(See Use #!/bin/sh or #!/bin/bash for Ubuntu-OSX compatibility and ease of use & POSIX) If I want my scripts to use the bash shell, does using the .bash extension actually invoke bash or does it … depend on system config / 1st shebang line. If both were in effect but different, which would have precedence? I'm not sure whether to end my scripts with .sh to just indicate "shell script" and then …
asked Feb 4 '15 by Michael Durrant
1
vote
I'm going for the bigger picture of "why it is legal" Answer: So that you can call or invoke a program and for that invocation only use a variable with a particular variable. As an example: You have …
answered Apr 28 '14 by Michael Durrant
1
vote
1answer
I can start zsh with zsh. How can I make it be the default for new terminal windows? Will it be ok to copy my .bashrc to .zshrc to get things like my customized PS1 prompt.
asked Sep 23 '14 by Michael Durrant

15 30 50 per page