Sponsored Content
Top Forums Shell Programming and Scripting Checking variable with specific string and stripping number from it. Post 302716961 by itkamaraj on Wednesday 17th of October 2012 10:58:49 AM
Old 10-17-2012
Code:
$ a=50m
$ echo ${a/m/}
50
$ a=50s
$ echo ${a/m/}
50s
$ a=50h
$ echo ${a/m/}
50h

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Number of specific char in a string.

I wish to compute the number of dot chars in a string. Example: VAR="aaaa.bbbbb.cccc" I try the shortest command to solve this test. Thanks in advance for your help. Regards, Giovanni (7 Replies)
Discussion started by: gio123bg
7 Replies

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

3. UNIX for Dummies Questions & Answers

Stripping a portion of string from behind!!!

Hi, How to strip a portion of a file name from behind...Say for Eg..i have a file name like aaaaa.bbbbb.Mar-17-2007 i want to remove .Mar-17-2007...is there a one line command which can give this output... Thanks Kumar (5 Replies)
Discussion started by: kumarsaravana_s
5 Replies

4. Shell Programming and Scripting

Stripping the spaces in a string variable

Hi , i have to strip the spaces in the string which has the following value ABC DEF i want this to appear like this ABC DEF is there any spilt method? please help.... Thanks (3 Replies)
Discussion started by: rag84dec
3 Replies

5. Shell Programming and Scripting

[csh] checking for specific character ranges in a variable

I want to check if a zip code is valid, using a variable that stores the zipcode. I am not sure how I would do this in a script. I know that simply checking for the numerical range of the number will not work, because '1' would be '00001' in zip code format. I know when I am in shell, I can use... (5 Replies)
Discussion started by: userix
5 Replies

6. Shell Programming and Scripting

How to extract variable number from a String

hi,I am new to shell script,I have String,like this: Number of rows exported: 5321 the numbe at end could changing,how can I extract this number and assign it to a variable,then use it later in script. thanks. (19 Replies)
Discussion started by: vitesse
19 Replies

7. Shell Programming and Scripting

stripping a variable down

I have a variable that has an absolute path for a file on my computer. This dynamically changes. Is there a way I can assign two new variables from that one? variable: /Users/keith/Desktop/test/file.mov 1) filename - no path or extention ....so just....file 2) path no filename or... (3 Replies)
Discussion started by: mainegate
3 Replies

8. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

9. Shell Programming and Scripting

Stripping characters from a variable

I'm using a shell script to get user input with this command: read UserInput I would then like to take the "UserInput" variable and strip out all of the following characters, regardless of where they appear in the variable or how many occurrences there are: \/":|<>+=;,?*@ I'm not sure... (5 Replies)
Discussion started by: nrogers64
5 Replies

10. Shell Programming and Scripting

Adding variable number of space in between two string

Hi, I am looking for the way to add variable number of spaces between two string. e.g input line is a ,bb abc ,bcb pqr ,bfg My output should be something like this a ,bb abc ,bcb pqr ,bfg This text... (9 Replies)
Discussion started by: diehard
9 Replies
Geography::NationalGrid::TW(3pm)			User Contributed Perl Documentation			  Geography::NationalGrid::TW(3pm)

NAME
Geography::NationalGrid::TW - Module to convert Taiwan Datum (TWD67/TM2, TWD97/TM2) to/from Latitude and Longitude SYNOPSIS
You should _create_ the object using the Geography::NationalGrid factory class, but you still need to know the object interface, given below. use Geography::NationalGrid; use Geography::NationalGrid::TW; # default TWD97 my $point1 = new Geography::NationalGrid::TW( 'Easting' => 302721.36, 'Northing' => 2768851.3995, ); printf("Point 1 is %f X and %f Y ", $point1->easting, $point1->northing); printf("Point 1 is %f N and %f E ", $point1->latitude, $point1->longitude); # transform to TWD67 $point1->transform('TWD67'); DESCRIPTION
Once created, the object allows you to retrieve information about the point that the object represents. For example you can create an object using easting / northing and the retrieve the latitude / longitude. OPTIONS
These are the options accepted in the constructor. You MUST provide either Latitude and Longitude, or Easting and Northing. Projection Default is 'TWD97', the "TAIWAN DATUM 97". Another projection recognized is 'TWD67', but only 'TWD97' is tested. GridReference There is no grid reference in Taiwan datum. Grid related functions are disabled. Latitude The latitude of the point. Actually should be the latitude using the spheroid related to the grid projection but for most purposes the difference is not too great. Specify the amount in any of these ways: as a decimal number of degrees, a reference to an array of three values (i.e. [ $degrees, $minutes, $seconds ]), or as a string of the form '52d 13m 12s'. North is positive degrees, south is negative degrees. Longitude As for latitude, except that east is positive degrees, west is negative degrees. Easting The number of metres east of the grid origin, using grid east. Northing The number of metres north of the grid origin, using grid north. Userdata The value of this option is a hash-reference, which you can fill with whatever you want - typical usage might be to specify "Userdata =" { Name => 'Dublin Observatory' }> but add whatever you want. Access using the data() method. METHODS
Most of these methods take no arguments. Some are inherited from Geography::NationalGrid latitude Returns the latitude of the point in a floating point number of degrees, north being positive. longitude As latitude, but east is positive degrees. easting How many metres east of the origin the point is. The precision of this value depends on how it was derived, but is truncated to an integer number of metres. northing How many metres north of the origin the point is. The precision of this value depends on how it was derived, but is truncated to an integer number of metres. deg2string( DEGREES ) Given a floating point number of degrees, returns a string of the form '51d 38m 34.34s'. Intended for formatting, like: $self->deg2string( $self->latitude ); data( PARAMETER_NAME ) Returns the item from the Userdata hash whose key is the PARAMETER_NAME. transform( PROJECTION ) Transform the point to the new projection, i.e. TWD67 to TWD97 or reverse. Return the point after transformation and keep original point intact. Uses the formula proposed by John Hsieh which is supposed to provide 2 meter accuracy conversions. ACCURACY AND PRECISION
The routines used in this code may not give you completely accurate results for various mathematical and theoretical reasons. In tests the results appeared to be correct, but it may be that under certain conditions the output could be highly inaccurate. It is likely that output accuracy decreases further from the datum, and behaviour is probably divergent outside the intended area of the grid. This module has been coded in good faith but it may still get things wrong. Hence, it is recommended that this module is used for preliminary calculations only, and that it is NOT used under any circumstance where its lack of accuracy could cause any harm, loss or other problems of any kind. Beware! REFERENCES
http://wiki.osgeo.org/wiki/Taiwan_datums John Hsieh - http://gis.thl.ncku.edu.tw/coordtrans/coordtrans.aspx AUTHOR AND COPYRIGHT
Copyright (c) 2006 Yen-Ming Lee "<leeym@leeym.com>". All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2009-09-06 Geography::NationalGrid::TW(3pm)
All times are GMT -4. The time now is 01:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy