How to read a file into a variable in shell?

In cross-platform, lowest-common-denominator sh you use: In bash or zsh, to read a whole file into a variable without invoking cat: Invoking cat in bash or zsh to slurp a file would be considered a Useless Use of Cat. Note that it is not necessary to quote the command substitution to preserve newlines. See: Bash Hacker’s Wiki – Command substitution – Specialities.

get “ERROR: Can’t get master address from ZooKeeper; znode data == null” when using Hbase shell

If you just want to run HBase without going into Zookeeper management for standalone HBase, then remove all the property blocks from hbase-site.xml except the property block named hbase.rootdir. Now run /bin/start-hbase.sh. HBase comes with its own Zookeeper, which gets started when you run /bin/start-hbase.sh, which will suffice if you are trying to get around … Read more

Is there a “goto” statement in bash?

No, there is not; see §3.2.4 “Compound Commands” in the Bash Reference Manual for information about the control structures that do exist. In particular, note the mention of break and continue, which aren’t as flexible as goto, but are more flexible in Bash than in some languages, and may help you achieve what you want. … Read more

How to convert a string to lower case in Bash?

The are various ways: POSIX standard tr AWK Non-POSIX You may run into portability issues with the following examples: Bash 4.0 sed Perl Bash Note: YMMV on this one. Doesn’t work for me (GNU bash version 4.2.46 and 4.0.33 (and same behaviour 2.05b.0 but nocasematch is not implemented)) even with using shopt -u nocasematch;. Unsetting that … Read more

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