Error handling in Bash [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 months ago. The community reviewed whether to reopen this question 4 months ago and left it closed: Original close reason(s) were … Read more

if arguments is equal to this string, define a variable like this string

I am doing some bash script and now I got one variable call source and one array called samples, like this: source=”country” samples=(US Canada Mexico…) as I want to expand the number of sources (and each source has its own samples) I tried to add some arguments to do this. I tried this: source=”” samples=(“”) … Read more

How can I ssh directly to a particular directory?

I often have to login to one of several servers and go to one of several directories on those machines. Currently I do something of this sort: localhost ~]$ ssh somehost Welcome to somehost! somehost ~]$ cd /some/directory/somewhere/named/Foo somehost Foo]$ I have scripts that can determine which host and which directory I need to get … Read more

What is the $? (dollar question mark) variable in shell scripting? [duplicate]

This question already has answers here: Meaning of $? (dollar question mark) in shell scripts (8 answers) Closed 3 years ago. I’m trying to learn shell scripting, and I need to understand someone else’s code. What is the $? variable hold? I can’t Google search the answer because they block punctuation characters. 9 Answers 9

How to execute a bash command stored as a string with quotes and asterisk [duplicate]

This question already has answers here: Why does shell ignore quoting characters in arguments passed to it through variables? [duplicate] (3 answers) Closed 6 years ago. I try to execute the following command : mysql AMORE -u username -ppassword -h localhost -e “SELECT host FROM amoreconfig” I store it in a string : cmd=”mysql AMORE … Read more