LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[CLUG] Shell script newbie

[CLUG] Shell script newbie

Francis Daly francisdaly at gmail.com
Wed Jan 7 21:48:36 GMT 2009


2009/1/7 Miloska <miloska at gmail.com>:
> On Wed, Jan 7, 2009 at 9:23 PM, Jean-Pierre Thibert
> <jpthibert at eircom.net> wrote:

>> 1)I have a variable with a value between 00.00 to 100.00 (ie : 12.58)
>> I want to extract the integer. Something like X=int(MYVAR)
>> How to do that? I didn't find out after a lot of research.

> not nice:
> echo "12.34" | cut -d . -f 1

A bit nicer, I think:

x=12.58
x=${x%.*}

Check the man page for details: remove a trailing pattern match from the string.

Good luck,

f


More information about the Cork mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell