Sponsored Content
Full Discussion: foo
Top Forums UNIX for Dummies Questions & Answers foo Post 302240037 by era on Thursday 25th of September 2008 01:25:33 AM
Old 09-25-2008
And tidier still to avoid the rat's nest of test backticks echo.

Code:
case $dow in
  $cld) 
    echo Its Cold for $sid at $c_dst
    $jobroot/scripts/abc.sh $sid COLD $c_dst;;
  $hot)
    echo Its Hot for $sid at $h_dst
    $jobroot/scripts/abc.sh $sid HOT $h_dst;;
  *)
    echo No backup for $sid today;;
esac

This assumes some things about how $dow and $cld and $hot are set up; you might need to tweak this if they are not simply one-to-one, but you get the idea. This is IMHO much more readable, as well as more efficient.

If $dow is the numeric day of the week and the values of $cld and $hot are something like 7 (signifying Sunday) and 135 (Mon Wed Fri), then perhaps

Code:
case $cld:$hot in
  *$dow*:*)  echo it's cold;;
  *:*$dow*)  echo it's hot;;
  *) echo it's not;;
esac

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find directories not containing foo, and copy foo to them

Hello all, I have a situation where I have a web root directory with a few thousand users spread out into 100 subdirectories in a 00/firstname.lastname, 01/firstname.lastname, etc. hierarchy. I suddenly need to make sure that each of these user directories contains a default index.html file... (6 Replies)
Discussion started by: dkaplowitz
6 Replies

2. Shell Programming and Scripting

Regex & grep-foo

I need a way to grep -v a list of times/date from the output of postqueue -p that are a few hours old, in order to remove them with postsuper -d. Right now I have a script that is deleting the previous day of messages left in the queue, which runs once each day. I want to clean up the job and... (1 Reply)
Discussion started by: DoneWithM$
1 Replies

3. Shell Programming and Scripting

if [ -z echo foo | egrep -e 'regexp' != '' ] -> dont work

Hallo, I need to test a String (a special ip number-string). So I want to run that: ipadress=172.0.0.0 # for debugging: echo $ipadress | egrep -e '172\.?\.??\.??$' # the test that doesnt work if test -z `echo $ipadress | egrep -e '172\.?\.??\.??$'` != "" then echo "match" else... (1 Reply)
Discussion started by: wiseguy
1 Replies

4. Shell Programming and Scripting

using /etc/foo.config in shell script

I'm very very new to shell scripting (about 4 hours) i've google'd till i can't google no more is it possible to have store values in a config file .e.g /etc/foo.conf data=/home/ mount=/dev/sda1 size=1GB and access these values from a shell script but also be able to use... (3 Replies)
Discussion started by: xpd259
3 Replies

5. Shell Programming and Scripting

SED: Extracting text between first occurance of foo in front of bar

Suppose I have a text file that contains the tags <foo> and <bar>. The text file can have unlimted occurances of <foo> and <bar> and looks somthing like this: <foo> Some Text <foo> Some Text <bar> Some Text <foo> Some (1 Reply)
Discussion started by: ArterialTool
1 Replies

6. UNIX for Dummies Questions & Answers

the meaning of "!:*" in "alias foo 'command\!:*' filename"

Hi: How can I remove my own post? Thanks. (2 Replies)
Discussion started by: phil518
2 Replies

7. UNIX for Dummies Questions & Answers

Odd result from cp -R foo/.* bar

I'm not all that much of a newbie but I've not encountered this before. Happens both in Cygwin and in Mac OS X (Darwin): cp -R /path/to/foo/.* /path/to/bar (where directory 'bar' exists) ... seems to copy not only the contents of directory 'foo', but also other directories that are... (3 Replies)
Discussion started by: ChapHarrison
3 Replies

8. UNIX for Dummies Questions & Answers

Having trouble understanding this command: >foo<bar bc

Sometimes it works for me and sometimes I get this error: syntax error on line 1, teletype Basically I've got no idea whats going on, especially at the end of the command: bc Any help is appreciated (1 Reply)
Discussion started by: phunkypants
1 Replies

9. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies
UNSET(3)								 1								  UNSET(3)

unset - Unset a given variable

SYNOPSIS
void unset (mixed $var, [mixed $...]) DESCRIPTION
unset(3) destroys the specified variables. The behavior of unset(3) inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is unset(3) inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset(3) was called. <?php function destroy_foo() { global $foo; unset($foo); } $foo = 'bar'; destroy_foo(); echo $foo; ?> The above example will output: bar To unset(3) a global variable inside of a function, then use the $GLOBALS array to do so: <?php function foo() { unset($GLOBALS['bar']); } $bar = "something"; foo(); ?> If a variable that is PASSED BY REFERENCE is unset(3) inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset(3) was called. <?php function foo(&$bar) { unset($bar); $bar = "blah"; } $bar = 'something'; echo "$bar "; foo($bar); echo "$bar "; ?> The above example will output: something something If a static variable is unset(3) inside of a function, unset(3) destroys the variable only in the context of the rest of a function. Fol- lowing calls will restore the previous value of a variable. <?php function foo() { static $bar; $bar++; echo "Before unset: $bar, "; unset($bar); $bar = 23; echo "after unset: $bar "; } foo(); foo(); foo(); ?> The above example will output: Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 23 PARAMETERS
o $var - The variable to be unset. o $... - Another variable ... RETURN VALUES
No value is returned. EXAMPLES
Example #1 unset(3) example <?php // destroy a single variable unset($foo); // destroy a single element of an array unset($bar['quux']); // destroy more than one variable unset($foo1, $foo2, $foo3); ?> Example #2 Using (unset) casting (unset) casting is often confused with the unset(3) function. (unset) casting serves only as a NULL-type cast, for completeness. It does not alter the variable it's casting. <?php $name = 'Felipe'; var_dump((unset) $name); var_dump($name); ?> The above example will output: NULL string(6) "Felipe" NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. Note It is possible to unset even object properties visible in current context. Note It is not possible to unset $this inside an object method since PHP 5. Note When using unset(3) on inaccessible object properties, the __unset() overloading method will be called, if declared. SEE ALSO
isset(3), empty(3), __unset(), array_splice(3). PHP Documentation Group UNSET(3)
All times are GMT -4. The time now is 10:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy