Sponsored Content
Top Forums Shell Programming and Scripting How to compare specific digit in number? Post 302916079 by RudiC on Saturday 6th of September 2014 03:28:05 PM
Old 09-06-2014
Use bash's parameter substring expansion: echo ${var:6:2}.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting 10 digit number from txt files

Hi, Was wondering if you could give me an example of extracting a 10 digit number from 5 txt files using a regular expression (the number is always different ) and storing the numbers in variables Thanks C19 (9 Replies)
Discussion started by: c19h28O2
9 Replies

2. Shell Programming and Scripting

adding a 6 digit number retaining 0s on the left

i am new to shell scripting. i want to keep on increamenting a 6 digit number. For eg. 000000 + 1 = 000001 But instead of 000001 i get only 1. How do i do this ? Pls help. (8 Replies)
Discussion started by: kanchan_cp
8 Replies

3. Programming

generating 16 digit random number in C

Hi, How can we generate 16 digit random nos in C. (10 Replies)
Discussion started by: ajaysahoo
10 Replies

4. Programming

Find out 2^n+1 , where n is a 3 digit number

I have to write a c program which takes a 3 digit number n and calculates the value of (2^n)+1 and then determines the number is prime or not. I have tried to first calculate the value of 2^n and then adding one to it and then apply the logic of prime number. but the ultimate problem is that... (7 Replies)
Discussion started by: agrawal.prachi
7 Replies

5. UNIX for Dummies Questions & Answers

list all files containing 4 digit number using grep

how can i list all files in my home directory that have a 4 digit id number, the line number where the id is located and the id itself not printing the entire line? (5 Replies)
Discussion started by: hobiwhenuknowme
5 Replies

6. Shell Programming and Scripting

Print a number up to last significant digit after decimal point

I want to write/print a number through a shell script up to its last significant digit (LSD) after the decimal point. Say, x=10.00056000000000000 I want to print x as x=10.00056. Note that x can be any thing so I cannot know the position of the LSD always. Thanks. (16 Replies)
Discussion started by: hbar
16 Replies

7. Shell Programming and Scripting

Regular expression for 6 digit number present in a line

Hello Team, i have a file test1.txt, in which i have to grep only the 6 digit number from it, Could you pls help in this. $cat test1.txt <description>R_XYZ_1.6 r370956</description> $ grep "\{6\}" test1.txt <description>R_XYZ_1.6 r370956</description> i need output as 370956. ... (3 Replies)
Discussion started by: chandana hs
3 Replies

8. Shell Programming and Scripting

Add tab after digit in specific field in file

I am trying to add a tab after the last digit in $3 in the input. The grep below is all I can think off. Thank you :) sed -n 's/:/&/p' input input chr1 955542 955763AGRN-6|gc=75 chr1 957570 957852AGRN-7|gc=61.2 chr1 976034 976270AGRN-9|gc=74.5 desired output chr1... (5 Replies)
Discussion started by: cmccabe
5 Replies

9. Shell Programming and Scripting

awk to update specific value in file with match and add +1 to specific digit

I am trying to use awk to match the NM_ in file with $1 of id which is tab-delimited. The NM_ will always be in the line of file that starts with > and be after the second _. When there is a match between each NM_ and id, then the value of $2 in id is substituted or used to update the NM_. Each NM_... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. UNIX for Beginners Questions & Answers

Process only 4 digit odd number starting with zero

I am trying to process only IonCode_odd #'s (always 4 digits starting with zero), but the below isn't working as expected. Is there a better way? Thank you :). IonCode_0401_xxxx_xxxx_xxxx.bam IonCode_0401_xxxx_xxxx_xxxx.bam.bai IonCode_0401_xxxx_xxxx_xxxx.fastq... (2 Replies)
Discussion started by: cmccabe
2 Replies
IS_SUBCLASS_OF(3)							 1							 IS_SUBCLASS_OF(3)

is_subclass_of - Checks if the object has this class as one of its parents

SYNOPSIS
bool is_subclass_of TRUE (mixed $object, string $class_name, [bool $allow_string]) DESCRIPTION
Checks if the given $object has the class $class_name as one of its parents. PARAMETERS
o $object - A class name or an object instance. No error is generated if the class does not exist. o $class_name - The class name o $allow_string - If this parameter set to false, string class name as $object is not allowed. This also prevents from calling autoloader if the class doesn't exist. RETURN VALUES
This function returns TRUE if the object $object, belongs to a class which is a subclass of $class_name, FALSE otherwise. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.9 | | | | | | | Added $allow_string parameter | | | | | 5.3.7 | | | | | | | Added support for $class_name to work with | | | interfaces | | | | | 5.0.3 | | | | | | | You may also specify the $object parameter as a | | | string (the name of the class) | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 is_subclass_of(3) example <?php // define a class class WidgetFactory { var $oink = 'moo'; } // define a child class class WidgetFactory_Child extends WidgetFactory { var $oink = 'oink'; } // create a new object $WF = new WidgetFactory(); $WFC = new WidgetFactory_Child(); if (is_subclass_of($WFC, 'WidgetFactory')) { echo "yes, $WFC is a subclass of WidgetFactory "; } else { echo "no, $WFC is not a subclass of WidgetFactory "; } if (is_subclass_of($WF, 'WidgetFactory')) { echo "yes, $WF is a subclass of WidgetFactory "; } else { echo "no, $WF is not a subclass of WidgetFactory "; } // usable only since PHP 5.0.3 if (is_subclass_of('WidgetFactory_Child', 'WidgetFactory')) { echo "yes, WidgetFactory_Child is a subclass of WidgetFactory "; } else { echo "no, WidgetFactory_Child is not a subclass of WidgetFactory "; } ?> The above example will output: yes, $WFC is a subclass of WidgetFactory no, $WF is not a subclass of WidgetFactory yes, WidgetFactory_Child is a subclass of WidgetFactory Example #2 is_subclass_of(3) using interface example <?php // Define the Interface interface MyInterface { public function MyFunction(); } // Define the class implementation of the interface class MyClass implements MyInterface { public function MyFunction() { return "MyClass Implements MyInterface!"; } } // Instantiate the object $my_object = new MyClass; // Works since 5.3.7 // Test using the object instance of the class if (is_subclass_of($my_object, 'MyInterface')) { echo "Yes, $my_object is a subclass of MyInterface "; } else { echo "No, $my_object is not a subclass of MyInterface "; } // Test using a string of the class name if (is_subclass_of('MyClass', 'MyInterface')) { echo "Yes, MyClass is a subclass of MyInterface "; } else { echo "No, MyClass is not a subclass of MyInterface "; } ?> The above example will output: Yes, $my_object is a subclass of MyInterface Yes, MyClass is a subclass of MyInterface NOTES
Note Using this function will use any registered autoloaders if the class is not already known. SEE ALSO
get_class(3), get_parent_class(3), is_a(3), class_parents(3). PHP Documentation Group IS_SUBCLASS_OF(3)
All times are GMT -4. The time now is 05:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy