Sponsored Content
Top Forums Shell Programming and Scripting check if a variable is not affected Post 302298336 by melanie_pfefer on Tuesday 17th of March 2009 09:47:25 AM
Old 03-17-2009
check if a variable is not affected

Hi all,

to check that a variable is not empty, I usually do:

if [ -z "$a" ]; then...
or
if [ -n "$a" ]; then...


what if I have a serie of variables and want to do the same test on all of them. How to do this in a single if statement?

thank you
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check if a variable contains a .

Hi I am writing a bash script and would like to check is a variable contains a . or not ex. a=102 output ok a=1.02 output not ok Many thanks, (3 Replies)
Discussion started by: gekkos
3 Replies

2. What is on Your Mind?

Were You Affected by Volcanic Activity in Iceland?

If you were effected by the volcanic activity in Iceland, share you vote and story here. ---------- Post updated at 04:15 ---------- Previous update was at 04:10 ---------- A friend of mine in Tokyo had a contracting job with a film production company. They had to cancel an event because... (2 Replies)
Discussion started by: Neo
2 Replies

3. Shell Programming and Scripting

Check if a variable is zero

I have seen many posts for this sort of problem but I just did not know how to use it for my issue. A number is assigned to a variable and I wanted to check if it is a zero or non zero. Example of my numbers are below: 000000000000000000000000000000000000000000000000... (8 Replies)
Discussion started by: soujiv
8 Replies

4. Shell Programming and Scripting

Check if a variable is having value

I have a script /root/asas with following contents. #!/bin/bash ha=`cat /etc/passwd | grep sandra` if ; then echo "Sandra is in /etc/passwd" echo "variable ha is $ha" else echo "Sandra is NOT in /etc/passwd" echo "variable ha is $ha" fi What... (3 Replies)
Discussion started by: anil510
3 Replies

5. UNIX for Dummies Questions & Answers

Problem with FreeBSD 8.3. BIOS affected

Hello everybody. I have a problem of this kind: After installation of FreeBSD, my Windows XP became unreachable. Boot from CDROM is impossible. The conclusion: BIOS was damaged by GParted or some other program. Question: Are there any Unix means of updating (repairing) BIOS ?:wall: (11 Replies)
Discussion started by: prabux
11 Replies

6. Shell Programming and Scripting

Check variable

Hi people, I would like to start a review of my config variable to check whether they have been changed and if not then there is only an echo. If they have been changed to my other commands are executed. I hope you can help me. with best regards JPad edit: here my code if ;... (8 Replies)
Discussion started by: JPad
8 Replies

7. AIX

High CPU Usage , users affected

Dear All, One production Server is affected by high usage. Application is slow now. Please guide me how to solve it? NMON Report shows full cpu usage. Here im posting some server details. bash-3.2# lparstat -i Node Name : ********* Partition Name ... (6 Replies)
Discussion started by: Thala
6 Replies

8. Cybersecurity

The Heartbleed Bug - What versions of the OpenSSL are affected?

Reference: The Heartbleed Bug What versions of the OpenSSL are affected? Status of different versions: OpenSSL 1.0.1 through 1.0.1f (inclusive) are vulnerable OpenSSL 1.0.1g is NOT vulnerable OpenSSL 1.0.0 branch is NOT vulnerable OpenSSL 0.9.8 branch is NOT vulnerable Bug was... (3 Replies)
Discussion started by: Neo
3 Replies
for(n)							       Tcl Built-In Commands							    for(n)

__________________________________________________________________________________________________________________________________________________

NAME
for - ``For'' loop SYNOPSIS
for start test next body _________________________________________________________________ DESCRIPTION
For is a looping command, similar in structure to the C for statement. The start, next, and body arguments must be Tcl command strings, and test is an expression string. The for command first invokes the Tcl interpreter to execute start. Then it repeatedly evaluates test as an expression; if the result is non-zero it invokes the Tcl interpreter on body, then invokes the Tcl interpreter on next, then repeats the loop. The command terminates when test evaluates to 0. If a continue command is invoked within body then any remaining commands in the current execution of body are skipped; processing continues by invoking the Tcl interpreter on next, then evaluating test, and so on. If a break command is invoked within body or next, then the for command will return immediately. The operation of break and continue are similar to the corresponding statements in C. For returns an empty string. Note: test should almost always be enclosed in braces. If not, variable substitutions will be made before the for command starts execut- ing, which means that variable changes made by the loop body will not be considered in the expression. This is likely to result in an infinite loop. If test is enclosed in braces, variable substitutions are delayed until the expression is evaluated (before each loop iter- ation), so changes in the variables will be visible. For an example, try the following script with and without the braces around $x<10: for {set x 0} {$x<10} {incr x} { puts "x is $x" } SEE ALSO
break, continue, foreach, while KEYWORDS
for, iteration, looping Tcl for(n)
All times are GMT -4. The time now is 12:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy