Bash script
1) What is the ${#HOSTNAME} means ?
2) I think hostname "$HOSTNAME" means set the variable hostname to whatever value is in HOSTNAME. 3) What is the difference between hostname "$HOSTNAME" and hostname $HOSTNAME ? ========================== if [${#HOSTNAME} -ne 0]; then hostname "$HOSTNAME" fi |
1) I have never seen a variable written with a hash (#) in front, so all I can assume is that the variables name is "#HOSTNAME" but I am probably totally wrong on this one...
2) Actually, this is running the "hostname" program with the value of "$HOSTNAME" as an argument. Variable assignment uses the equals sign ie: hostname=$HOSTNAME 3) Quoting the variable preserves whitespace when referencing it. ie: Code:
hello="A B C D" http://www.tldp.org/LDP/abs/html/index.html |
reply
Thank you bulliver for your help.
|
Re: Bash script
Quote:
In other words: the length of $HOSTNAME. For example if HOSTNAME is "Linh", then "echo $(#HOSTNAME)" prints "4". If it is "Hko", then it prints "3". |
reply
Thank you HKo for your help
|
All times are GMT -5. The time now is 07:10 AM. |