Sponsored Content
Full Discussion: Getting number from a string
Top Forums Shell Programming and Scripting Getting number from a string Post 302882318 by bartus11 on Monday 6th of January 2014 06:58:36 AM
Old 01-06-2014
Try:
Code:
number=`echo $string | tr -d 'a-zA-Z'`

This User Gave Thanks to bartus11 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell to number and to string

Hello Does the unix korn shell provide a function to convert between number and string data-types regards Hrishy (1 Reply)
Discussion started by: xiamin
1 Replies

2. Shell Programming and Scripting

string to number

In the following script when I get SIZE1 and SIZE2, they are of type string. I can not do any mathematical operations on them. I wanted to find out if I can convert string in to Number. Thanks in Advance. FILE1='/export/registry/incoming/reg.dmp' FILE2='/export/registry/reg.dmp' SIZE1=`ls... (2 Replies)
Discussion started by: George_king
2 Replies

3. Shell Programming and Scripting

$A is a number / any other string? How to determine ?

I have a variable (say $A) and while passing it gets either a number or some other string. Now how can test (with if else) whether the variable is just a ne or something else ? Thanks a lot to all in advance C Saha (2 Replies)
Discussion started by: csaha
2 Replies

4. Shell Programming and Scripting

extracting a number from a string

Hi everyone, I have a string as follow ts1n65ulpa4096x16m16_130a_ss1p08v125c i would like to extract 4096 and 16 from string and save it into two variable. but this string could also have the form ts1n65ulpa32x16m16_130a_ss1p08v125c therefore the number before "x" could be 2 or 3 digits. i use... (6 Replies)
Discussion started by: ROOZ
6 Replies

5. UNIX for Dummies Questions & Answers

Number of lines containing a certain string

Hey I want to know if there is an option to know the number of lines containing a certain string (bit for example) in a file? Say I want to know number of lines containing only the string BIT in file xyz. I know how to get number of lines in a file by using wc -l but how do you get number of lines... (1 Reply)
Discussion started by: #moveon
1 Replies

6. Shell Programming and Scripting

number of characters in a string

Hi there, I have some user input in a variable called $VAR, and i need to ensure that the string is 5 or less characters .... does anybody know how i can count the characters in the variables ? any help would be great, cheers (2 Replies)
Discussion started by: rethink
2 Replies

7. Shell Programming and Scripting

Python String <--> Number

My question is so simple: A = raw_input("A ") if A == '56': VAR = (A + 54)/13 else: print "other operations" if I write in input 5656565656 i want to make some arithmetic operations if the first input is 56XXX but the output is TypeError: cannot concatenate 'str' and... (2 Replies)
Discussion started by: kazikamuntu
2 Replies

8. Shell Programming and Scripting

string to number problem

Hi actually what happen i have taken a value from database table and stored in variable and that value is 20100601 000000 but this value is stored as string value in database table so after storing this value in variable a when i did operation on this a variable like a=`expr ${a} +1` i m... (1 Reply)
Discussion started by: aishsimplesweet
1 Replies

9. 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

10. 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
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 10:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy