11-27-2008
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,
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
If I have a variable $X, how do I check it is a number?
Many thanks. (2 Replies)
Discussion started by: handak9
2 Replies
2. Shell Programming and Scripting
Hello
I want to check for NULL variable..
but this is not working..please help
thanks in advance
esham (2 Replies)
Discussion started by: esham
2 Replies
3. Shell Programming and Scripting
Hello All,
I have a script that will email out if the email address is specified as parameter 1.
I am using ksh, and then tried the following :
email=$1
Following did not work, I am getting error
test -z $email
test ${email:=" ") -eq " "
test -n $email
test ${?email}
What... (4 Replies)
Discussion started by: negixx
4 Replies
4. Shell Programming and Scripting
Hi all,
to check that a variable is not empty, I usually do:
if ; then...
or
if ; 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 (1 Reply)
Discussion started by: melanie_pfefer
1 Replies
5. UNIX for Dummies Questions & Answers
hi to all,
i want to check the value of a variable that it contains characters.
for example i try the following:
if then .........
i just want to check that in the specific line that is a variable called "passline" has the entry "password". But it can contain also other characters in the... (4 Replies)
Discussion started by: omonoiatis9
4 Replies
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
#!/bin/sh
echo "Running Script to capture ORACLE Erros"
# Change Directory to the actual logs path
cd /home/nv8510/lognew
err_var=`grep -in "ORA-" *`
if then
echo "THESE ARE THE ORACLE ERROR OCCURED"
echo "$err_var"
echo... (7 Replies)
Discussion started by: neeraj617
7 Replies
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
hi,
i want to check whether a a variable contains some value or is empty in a shell script. so if the variable contains some value i want to do some job and if the variable doesnt contain any value then i need to skip that job.
here is a sample script
read_filenames.sh contains
... (5 Replies)
Discussion started by: Little
5 Replies
10. Shell Programming and Scripting
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
LEARN ABOUT XFREE86
libbash
LIBBASH(7) libbash Manual LIBBASH(7)
NAME
libbash -- A bash shared libraries package.
DESCRIPTION
libbash is a package that enables bash dynamic-like shared libraries. Actually its a tool for managing bash scripts whose functions you may
want to load and use in scripts of your own.
It contains a 'dynamic loader' for the shared libraries ( ldbash(1)), a configuration tool (ldbashconfig(8)), and some libraries.
Using ldbash(1) you are able to load loadable bash libraries, such as getopts(1) and hashstash(1). A bash shared library that can be loaded
using
ldbash(1) must answer 4 requirments:
1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash).
2. It must contain a line that begins with '#EXPORT='. That line will contain (after the '=') a list of functions that the library
exports. I.e. all the function that will be usable after loading that library will be listed in that line.
3. It must contain a line that begins with '#REQUIRE='. That line will contain (after the '=') a list of bash libraries that are
required for our library. I.e. every bash library that is in use in our bash library must be listed there.
4. The library must be listed (For more information, see ldbashconfig(8)).
Basic guidelines for writing library of your own:
1. Be aware, that your library will be actually sourced. So, basically, it should contain (i.e define) only functions.
2. Try to declare all variables intended for internal use as local.
3. Global variables and functions that are intended for internal use (i.e are not defined in '#EXPORT=') should begin with:
__<library_name>_
For example, internal function myfoosort of hashstash library should be named as
__hashstash_myfoosort
This helps to avoid conflicts in global name space when using libraries that come from different vendors.
4. See html manual for full version of this guide.
AUTHORS
Hai Zaar <haizaar@haizaar.com>
Gil Ran <ril@ran4.net>
SEE ALSO
ldbash(1), ldbashconfig(8), getopts(1), hashstash(1) colors(1) messages(1) urlcoding(1) locks(1)
Linux Epoch Linux