Getting an “ambiguous redirect” error

Bash can be pretty obtuse sometimes. The following commands all return different error messages for basically the same error: Adding quotes around the variable seems to be a good way to deal with the “ambiguous redirect” message: You tend to get a better message when you’ve made a typing mistake — and when the error … Read more

Laravel PHP Command Not Found

Ok, I did that and it works: And paste do source ~/.bash_profile and enjoy 😉 Important: If you want to know the difference between bash_profile and bashrc please check this link Note: For Ubuntu 16.04 running laravel 5.1, the path is: ~/.config/composer/vendor/bin On other platforms: To check where your Composer global directory is, run composer global about. Add /vendor/bin to the directory that gets listed after “Changed … Read more

Bash if statement with multiple conditions throws an error

Use -a (for and) and -o (for or) operations. tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html Update Actually you could still use && and || with the -eq operation. So your script would be like this: Although in your case you can discard the last two expressions and just stick with one or operation like this:

Simple logical operators in Bash

What you’ve written actually almost works (it would work if all the variables were numbers), but it’s not an idiomatic way at all. (…) parentheses indicate a subshell. What’s inside them isn’t an expression like in many other languages. It’s a list of commands (just like outside parentheses). These commands are executed in a separate subprocess, so … Read more

How to escape single quotes within single quoted strings

If you really want to use single quotes in the outermost layer, remember that you can glue both kinds of quotation. Example: Explanation of how ‘”‘”‘ is interpreted as just ‘: ‘ End first quotation which uses single quotes. ” Start second quotation, using double-quotes. ‘ Quoted character. ” End second quotation, using double-quotes. ‘ Start third quotation, using single quotes. If you … Read more

How to define hash tables in Bash?

Bash 4 Bash 4 natively supports this feature. Make sure your script’s hashbang is #!/usr/bin/env bash or #!/bin/bash so you don’t end up using sh. Make sure you’re either executing your script directly, or execute script with bash script. (Not actually executing a Bash script with Bash does happen, and will be really confusing!) You declare an associative array by doing: You can fill it up with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)