Good morning,

On 14/10/14 at 2:29 PM -0700, Greg Raven <[email protected]> wrote:

Is there such a thing as variables for Unix worksheets? I've checked the Users Manual but didn't find anything. Maybe that's just me, though.

Not for worksheets, but you can use ENV or shell variables. Worksheets are really just a type of terminal to access a shell. (The status bar at the bottom will show which shell is being used.)

All the standard variable assignments and evaluation should work just fine. There are subtle differences between the different shell types though. My examples (below) work for bash.

unix-worksheet-variable = "MX"
dig -t %unix-worksheet-variable% example.org
dig -t %unix-worksheet-variable% example.com
dig -t %unix-worksheet-variable% example.net
dig -t %unix-worksheet-variable% example.info
dig -t %unix-worksheet-variable% example.biz

would become:

export rectype="MX"
dig -t $rectype example.org
dig -t $rectype example.com
dig -t $rectype example.net
dig -t $rectype example.info
dig -t $rectype example.biz


But combine some looping and it gets better:

export rectype="MX"
for dom in example.org example.com example.net example.info example.biz
do
  dig -t $rectype $dom
done


Or shorten it to two lines:

export rectype="MX"
for dom in example.org example.com example.net example.info example.biz; do dig -t $rectype $dom; done


Get even fancier:

for rectype in A MX NS TXT
do
  for dom in example.org example.com example.net example.info example.biz
  do
    dig -t $rectype $dom
  done
done


Use shell variables in your worksheets and enjoy the power.


Charlie

--
   Charlie Garrison  <[email protected]>
   github.com/cngarrison   metacpan.org/author/CNG

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

--
This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to