Sponsored Content
Top Forums Shell Programming and Scripting How to check whether a string is number or not Post 83964 by shihabvk on Wednesday 21st of September 2005 05:24:11 AM
Old 09-21-2005
How to check whether a string is number or not

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
34+45 -- non number

please help me
Shihab
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

check whether variable number or string

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

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

3. Shell Programming and Scripting

how to search string and number in one file and check in the other file

Hi, Can anyone help in the below problem. file1 has the below contents fileset 999 primary-ilist inode 37020 has invalid dotdot (426094) -> Not exist fileset 999 primary-ilist inode 115016 dup block ->... (9 Replies)
Discussion started by: knshree
9 Replies

4. Shell Programming and Scripting

How to Check given string is number in shell script?

Hi, Can anyone help me out to check whether the input argument is number? Example: REQUEST_ID="123456" I need to check the REQUEST_ID value is number or string. Thanks in Advance Regards BS (6 Replies)
Discussion started by: balajiora
6 Replies

5. Shell Programming and Scripting

Check if the value is Number

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

6. Shell Programming and Scripting

changing number in bash (number is in form of string)

I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as name1:name2:name3:1 when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Discussion started by: Learnerabc
3 Replies

7. Shell Programming and Scripting

Check parameter is number or string

Hey I'm new in linux, I'm looking for a code to check whether the parameter is a number or a string. I have already tried this code: eerste=$(echo $1 | grep "^*$">aux) if But it doesn't work.:confused: Thanks (2 Replies)
Discussion started by: Eclecticaa
2 Replies

8. Shell Programming and Scripting

Check file for string existence before appending it with string

I want to append file with a string but before doing that i want to check if this string already exist in that file.I tried with grep on Solaris 10 but unsuccessful.Man pages from grep seems to suggest if the string is found command status will be 0 and if not 1.But i am not finding it.May be i... (2 Replies)
Discussion started by: sahil_shine
2 Replies

9. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies
HUNT(6) 							   Games Manual 							   HUNT(6)

NAME
hunt - a multi-player multi-terminal game SYNOPSIS
/usr/games/hunt [-q] [-m] [hostname] [-l name] DESCRIPTION
The object of the game hunt is to kill off the other players. There are no rooms, no treasures, and no monsters. Instead, you wander around a maze, find grenades, trip mines, and shoot down walls and players. The more players you kill before you die, the better your score is. If the -m flag is given, you enter the game as a monitor (you can see the action but you cannot play). Hunt normally looks for an active game on the local network; if none is found, it starts one up on the local host. One may specify the location of the game by giving the hostname argument. The player name may be specified on the command line by using the -l option. This command syntax was chosen for rlogin/rsh compatibility. If the -q flag is given, hunt queries the network and reports if an active game were found. This is useful for .login scripts. Hunt only works on crt (vdt) terminals with at least 24 lines, 80 columns, and cursor addressing. The screen is divided in to 3 areas. On the right hand side is the status area. It shows you how much damage you've sustained, how many charges you have left, who's in the game, who's scanning (the asterisk in front of the name), who's cloaked (the plus sign in front of the name), and other players' scores. Most of the rest of the screen is taken up by your map of the maze, except for the 24th line, which is used for longer messages that don't fit in the status area. Hunt uses the same keys to move as vi does, i.e., h,j,k, and l for left, down, up, right respectively. To change which direction you're facing in the maze, use the upper case version of the movement key (i.e., HJKL). Other commands are: f - Fire (in the direction you're facing) (Takes 1 charge) g - Throw grenade (in the direction you're facing) (Takes 9 charges) F - Throw satchel charge (Takes 25 charges) G - Throw bomb (Takes 49 charges) o - Throw small slime bomb (Takes 15 charges) O - Throw big slime bomb (Takes 30 charges) s - Scan (show where other players are) (Takes 1 charge) c - Cloak (hide from scanners) (Takes 1 charge) ^L - Redraw screen q - Quit Knowing what the symbols on the screen often helps: -|+ - walls / - diagonal (deflecting) walls # - doors (dispersion walls) ; - small mine g - large mine : - shot o - grenade O - satchel charge @ - bomb s - small slime bomb $ - big slime bomb ><^v - you facing right, left, up, or down }{i! - other players facing right, left, up, or down * - explosion |/ -*- - grenade and large mine explosion /| Satchel and bomb explosions are larger than grenades (5x5, 7x7, and 3x3 respectively). Other helpful hints: [] You can only fire in the direction you are facing. [] You can only fire three shots in a row, then the gun must cool. [] A shot only affects the square it hits. [] Shots and grenades move 5 times faster than you do. [] To stab someone, you must face that player and move at them. [] Stabbing does 2 points worth of damage and shooting does 5 points. [] Slime does 5 points of damage each time it hits. [] You start with 15 charges and get 5 more for every new player. [] A grenade affects the nine squares centered about the square it hits. [] A satchel affects the twenty-five squares centered about the square it hits. [] A bomb affects the forty-nine squares centered about the square it hits. [] Slime affects all squares it oozes over (15 or 30 respectively). [] One small mine and one large mine is placed in the maze for every new player. A mine has a 5% probability of tripping when you walk directly at it; 50% when going sideways on to it; 95% when backing up on to it. Tripping a mine costs you 5 points or 10 points respec- tively. Defusing a mine is worth 1 charge or 9 charges respectively. [] You cannot see behind you. [] Scanning lasts for (20 times the number of players) turns. Scanning takes 1 ammo charge, so don't waste all your charges scanning. [] Cloaking lasts for 20 turns. [] Whenever you kill someone, you get 2 more damage capacity points and 2 damage points taken away. [] Maximum typeahead is 5 characters. [] A shot destroys normal (i.e., non-diagonal, non-door) walls. [] Diagonal walls deflect shots and change orientation. [] Doors disperse shots in random directions (up, down, left, right). [] Diagonal walls and doors cannot be destroyed by direct shots but may be destroyed by an adjacent grenade explosion. [] Slime goes around walls, not through them. [] Walls regenerate, reappearing in the order they were destroyed. One percent of the regenerated walls will be diagonal walls or doors. When a wall is generated directly beneath a player, he is thrown in a random direction for a random period of time. When he lands, he sustains damage (up to 20 percent of the amount of damage he had before impact); that is, the less damage he had, the more nimble he is and therefore less likely to hurt himself on landing. [] The environment variable HUNT is checked to get the player name. If you don't have this variable set, hunt will ask you what name you want to play under. If it is set, you may also set up a single character keyboard map, but then you have to enumerate the options: e.g. setenv HUNT ``name=Sneaky,mapkey=zoFfGg1f2g3F4G'' sets the player name to Sneaky, and the maps z to o, F to f, G to g, 1 to f, 2 to g, 3 to F, and 4 to G. The mapkey option must be last. [] It's a boring game if you're the only one playing. Your score is the ratio of number of kills to number of times you entered the game and is only kept for the duration of a single session of hunt. Hunt normally drives up the load average to be about (number_of_players + 0.5) greater than it would be without a hunt game executing. A limit of three players per host and nine players total is enforced by hunt. FILES
/usr/games/lib/hunt.driver game coordinator AUTHORS
Conrad Huang, Ken Arnold, and Greg Couch; University of California, San Francisco, Computer Graphics Lab ACKNOWLEDGEMENTS
We thank Don Kneller, John Thomason, Eric Pettersen, and Scott Weiner for providing endless hours of play-testing to improve the character of the game. We hope their significant others will forgive them; we certainly don't. BUGS
To keep up the pace, not everything is as realistic as possible. There were some bugs in early releases of 4.2 BSD that hunt helped discover; hunt will crash your system if those bugs haven't been fixed. 4.3 Berkeley Distribution January 9, 1986 HUNT(6)
All times are GMT -4. The time now is 01:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy