|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The True Story of Unix Shell 'IF'
Jan. 28th, 2009 13:16 by sdeluca — Permalink | TrackBack: http://stephanedeluca.com/trackback/858 | — Sorry, this content is not available in english.I came across an issue with one of my server script while I was giving it a refresh this morning. The script is a backup script that lays on every single box of my cluster which purpose is to make the backup of each box in regards of each individual box role in the cluster. So I which to (pseudo) code the following:
Which I too much quickly translated in shell script as follows:
And guess what? you're right, it doesn't work. Shell complains as follows (HOST contains 'ns651' on this box):
It simply shocked me in the very first seconds I read this report, but quickly felt as Newton did with his "Eureka". What you might consider as a pure sheel syntax -- the square brackets -- is not actually! So what's this?
Alright, It fails because I forgot to put blanks between the command and the arguments! Hence the command it though I was interested in was In fact So insert all missing blanks between the command and its options and all will work as expected. Finally the correct syntax is obviously as follows:
Hope this reminder pleased you and this learning session just proves something important: how Unix -- which, at first sight, could be considered as a deprecated technology of the 70s -- is really not. The answer is probably: simplicity. And simplicity here means power and evolution. CommentsBe the first to leave a comment. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright © 1994 ˜ 2012 dsei.biz / Stéphane de Luca — All Rights Reserved
| 08:43 AM
| RSS Feed
| Best viewed with Safari
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||