03-01-2005
You can also use typeset -i to define your variable as an integer. You would also have to dump the error stream to /dev/null if you attempt to assign a string to the variable (this is easily done by simply by redirection 2> /dev/null)
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am passing an argument to a file and i wanna check whether the argument is a number or string ?
how can i do this? (4 Replies)
Discussion started by: rolex.mp
4 Replies
2. Shell Programming and Scripting
Logic of code
if ( $var is a number ) {
Do something
}
else {
Do something else
}
My question is: How do I check if a variable is a number. All the reg ex that I came up with to match this is failing. Please help. (3 Replies)
Discussion started by: garric
3 Replies
3. Shell Programming and Scripting
Hi ,
I am facing a problem .. which looks simple... but took 2 days of mine.. even now it is not solved completely..
I have one variable..., want to know whether that variable contains number... canbe +ve or -ve ...
Values
+35 --- number
-43 --- number
45A -- non number... (12 Replies)
Discussion started by: shihabvk
12 Replies
4. Shell Programming and Scripting
Hi,,
this is returning true in all cases..( other than 10 dig number also)
what could be wrong?? (2 Replies)
Discussion started by: shellwell
2 Replies
5. Shell Programming and Scripting
I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later.
Ex. 1 some data
2 something else
3 more stuff
which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies
6. Shell Programming and Scripting
Hi,
I have one file like 00123. And this file name is generated as a sequence.
So how can I confirm the generated file name is a number, not a special character or alphabets.
Can anybody help me out.
Thanks in advance. (3 Replies)
Discussion started by: Kattoor
3 Replies
7. Shell Programming and Scripting
Hi,
I have a file with data as given
$cat file1.txt
123
234
23e
234.456
234.876e
345.00
I am checking if the values are proper integers using the command.
nawk -F'|' 'int($1)!=$1 {printf "Error in field 1|"$0"\n"}' file1.txt
This is checking for only integers ( without... (10 Replies)
Discussion started by: ashwin3086
10 Replies
8. Shell Programming and Scripting
Hi guys, I am working on a server where there are many users. The user names end in a 1 or a 2. I want to write a bash script that will say which users are in which group and was wondering if I could get some help. The only part I am unsure of is how to check if it ends in the number.
Here's... (2 Replies)
Discussion started by: wua05
2 Replies
9. Shell Programming and Scripting
I have 2 and three params, both I should make sure thay numbers at one single line insted of checking for each one .
Example I wroote the following way.. checking for 2 and three seperately but I shud be able to do it at on statement
echo $2 | egrep '^+$' >/dev/null 2>&1
if ; then
echo... (2 Replies)
Discussion started by: raopatwari
2 Replies
10. Shell Programming and Scripting
Hi,
We are getting a curios result in one of AIX script. Its executed using !/bin/ksh .
After following line we get result of 3 in in the variable instance_count.
instance_count=`ps -ef | grep "script_check_instances.sh" | grep -v "grep" | wc -l`
But once we do a "ps -aef | grep... (2 Replies)
Discussion started by: niba
2 Replies
SINCE(1) User Manuals SINCE(1)
NAME
since - display content of a file since the last time
SYNOPSIS
since [-aefhlmnqvxz] [-d seconds] [-s file] files
DESCRIPTION
since is a utility designed to monitor log files. since is similar to tail(2) as it also displays information appended to a file. However
since only displays the data which has been added since the last time since was run. If since is run on a particular file for the first
time, then the entire file is displayed.
EXAMPLE
since /var/log/apache/{access,error}_log > /dev/null
lynx --dump http://localhost/ > /dev/null
since /var/log/apache/{access,error}_log
OPTIONS
-a Make updates to the since state files atomic. This option configures since to use a temporary file and a rename(2) instead of updat-
ing the state file in situ.
-d seconds
Specify the number of integer seconds to wait between polling files for changes. This option is only relevant in conjunction with
the -f option and if the inotify mechanism is not being used.
-e Print the header lines to standard error instead of standard output.
-f Follow the specified files. This option is analogous to tail -f as the files are also polled for changes until the process is inter-
rupted.
-h Print a terse help message.
-l Relaxed mode. If some data files are inaccessible since will not fail completely.
-m Disable mmap(2), use read(2) instead to access state and data files. Note that for certain smaller io operations read(2) may be
used even if this option has not been given.
-n Do not update the .since file which keeps track of file growth.
-q Make the utility operate more quietly.
-s filename
Specify the state file explicitly. Using this option will also disable the use of fallback state files.
-v Increase the verbosity. This option can be given multiple times.
-x Ignore file arguments which have compressed extensions.
-z Discard output. Similar to redirecting the output to /dev/null, but faster. If used in conjunction with the -f option, only the ini-
tial output will be discarded.
FILES
.since
State file recording the length of the previously displayed files. The location of the file can be set on the command line using
the -s option. If this option is not given, since will check the SINCE environment variable for the location of the state file. If
the SINCE environment variable has not been set since will use the HOME environment variable and store the information in the file
$HOME/.since. If the HOME variable is not set, since will use a getpwuid(3) lookup. If all these fail will use the file /tmp/since.
BUGS
since uses the inode of a file as its key, if that inode is recycled since will get confused. since is not particularly efficient when
storing or looking up the stat(2) information. Functionality equivalent to since can probably be achieved with a number of trivial shell
scripts.
COPYING
since may only be used, distributed and modified in accordance with the terms of the GPL (GNU General Public License) version 3 or newer as
published by the FSF (Free Software Foundation).
SEE ALSO
tail(1), stat(2).
Linux JULY 1998 SINCE(1)