Skip to main content
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
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
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 not deleted user 157411

Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.). Check scripts with https://shellcheck.net before posting.

2 votes

Nested if statements with 4 if

To help you understand what's wrong with your attempt (and you don't tell us what fails and what you expect, relying on us to guess), I just changed the indentation of your code, formatting it in a wa …
Murphy's user avatar
  • 2,709
2 votes

For loop in nohup

It would be much easier (read: more read- and maintainable) if you divide your code into two scripts: One to execute the actual function(s), and one to start them. Sample code for the latter: for i i …
Murphy's user avatar
  • 2,709
2 votes

bash find exec cp parents in script

I guess you're not really in the directory DIR; you execute cd in a subshell, but the working directory for the remaining commands stays at $TgtDir$c/$DirNew. You can verify this by calling pwd after …
Murphy's user avatar
  • 2,709
-1 votes

How can I check that two input values are correct in a bash script?

Just add the second condition to the expression using the or operator -o.
Murphy's user avatar
  • 2,709
-1 votes

What are some of the most useful aliases and bash scripts?

alias l="ls -l" alias la="ls -la" alias lsa="ls -a" alias ..="cd .." alias ...="cd ../.." alias df="df -h" alias ps="ps -ef" alias info="pinfo -a" alias man="pinfo -a -m" alias top="htop" alias tree=" …
Murphy's user avatar
  • 2,709
5 votes
Accepted

Catch unexpected input on single character read in bash

This statement should work properly: if [ "${uc,,}" != "y" ] Explanation: When uc is empty your test is expanded by the shell as follows: if [ != "y" ] while with the quotes it is if [ "" != " …
Murphy's user avatar
  • 2,709
2 votes
Accepted

Is it possible to use functions declared in a shell flavor in another shell type

It should be easy enough to create a wrapper script around the functions; for Bash: #!/bin/bash doSomething() { ... } doSomethingElse() { ... } FUNCTION_NAME=$1 shift ${FUNCTION_NAME} "$@" …
Murphy's user avatar
  • 2,709
0 votes
Accepted

You called the script without passing the environment variables, please run as sudo with -E ...

The install script prints this message when the environment variable JAVA_HOME isn't set (line 18). The README tells you how you're supposed to do that. You either haven't followed that manual, or it' …
Murphy's user avatar
  • 2,709
1 vote

Looking for command line package for showing inline text-based menu selector with arrow keys

A very basic approach to this would be to use bash's select statement; no need to install anything (else). Here's an example I've just got at hand: #!/bin/bash [...] sourceBranch= targetBranch= # F …
Murphy's user avatar
  • 2,709