In BASH, how does ||: get interpreted. I know || is logical or. And I believe : evaluates to true. Can someone give a thorough explanation for this usage?
Probably a simple one.
Basically I am retrieving a number from a file - setting a variable against it and then incrementing this by 1 and using this as an entry number in a log file for messages. I need the variable to re-evalute itself each time I call it so I get the latest number in the file -... (1 Reply)
Hi,
Could someone please help me with how to do the following?
Say I have a flat file test.lst and the content of the file is:
Report Date - `date '+%m%d%Y'`
I'm trying the following
while read myLine
do
echo ${myLine}
done<test.lst
This prints Report Date - `date... (1 Reply)
I have variables:
FOO="Text"
BAR="FOO"
I'd like to be able to evaluate the variable named as the value of $BAR.
echo $FOO
Text
echo $BAR
FOO
This is what I'd like to do:
echo ${$BAR} (this won't work)
Text (3 Replies)
Let's say for example that we have two different ways was can code the exact same program to achieve the same result.
What is the best way to determine which of the two methods is the best solution?
Is it as simple as basing it on how long the program takes to run or is there a more... (4 Replies)
Hi all,
I have a script that runs perfectly from cmd, but in the cron it gives a strange ':::::::::::::::' output instead of evaluating the part inside the quotes.
this is the script:
bash-3.00# more test
#!/bin/ksh
#-----swap---
TEMP_FILE=/HealthCheck/test/file.txt
swap -s | tee... (1 Reply)
How to evaluate the value of a variable ?
For example:
a=var
$a=value !!!error happens!!!
I want to evaluate var=value, how to realize it?
Thanks!
---------- Post updated at 03:37 AM ---------- Previous update was at 02:22 AM ----------
I am using linux bash.
a=var
$a=value... (4 Replies)
Hi,
I am trying to set a variable that has time the format desired. And my intention is to echo variable (instead of actual date command) everytime I like to echo date. Please take a look at below code.
$NOW=''
echo $NOW
After 5 minutes
$echo $NOW
Issue here is , I am not... (2 Replies)
I want to create a conditional expression string and pass in an awk script. My script is as below...
comm="\$3 == "hello""
awk -F "^T" -v command="${comm}" ' {
if ( command ) { print "hye" }
}' testBut the statement "if ( command )" always evaluates to true which is not... (5 Replies)
I have to display only those subscribers which are in "unconnected state" and the date is 90 days older than today's date.
Below command is used for this purpose:
cat vfsubscriber_20170817.csv | sed -e 's/^"//' -e '1d' | \
nawk -F '",' '{if ( (substr($11,2,4) == 2017) && ( substr($11,2,8)... (1 Reply)
Discussion started by: dia
1 Replies
LEARN ABOUT DEBIAN
if
if(3tcl) Tcl Built-In Commands if(3tcl)__________________________________________________________________________________________________________________________________________________NAME
if - Execute scripts conditionally
SYNOPSIS
if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN?
_________________________________________________________________DESCRIPTION
The if command evaluates expr1 as an expression (in the same way that expr evaluates its argument). The value of the expression must be a
boolean (a numeric value, where 0 is false and anything is true, or a string value such as true or yes for true and false or no for false);
if it is true then body1 is executed by passing it to the Tcl interpreter. Otherwise expr2 is evaluated as an expression and if it is true
then body2 is executed, and so on. If none of the expressions evaluates to true then bodyN is executed. The then and else arguments are
optional "noise words" to make the command easier to read. There may be any number of elseif clauses, including zero. BodyN may also be
omitted as long as else is omitted too. The return value from the command is the result of the body script that was executed, or an empty
string if none of the expressions was non-zero and there was no bodyN.
EXAMPLES
A simple conditional:
if {$vbl == 1} { puts "vbl is one" }
With an else-clause:
if {$vbl == 1} {
puts "vbl is one"
} else {
puts "vbl is not one"
}
With an elseif-clause too:
if {$vbl == 1} {
puts "vbl is one"
} elseif {$vbl == 2} {
puts "vbl is two"
} else {
puts "vbl is not one or two"
}
Remember, expressions can be multi-line, but in that case it can be a good idea to use the optional then keyword for clarity:
if {
$vbl == 1 || $vbl == 2 || $vbl == 3
} then {
puts "vbl is one, two or three"
}
SEE ALSO expr(3tcl), for(3tcl), foreach(3tcl)KEYWORDS
boolean, conditional, else, false, if, true
Tclif(3tcl)