Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 31st January 2007, 03:30 PM
chris_y2k_r1 Offline
Registered User
 
Join Date: Feb 2006
Location: PA
Posts: 135
Linux Bash Script

I have a couple of questions about bash scripting. I hope I've posed this in the right forum...

Anyway, I need to find a command that will extract the integer value of a numeric variable. For example, let's say the following:

let x=4.5
echo int(x)

Where int would be the integer value of x, if int was the actual command, then output would be 4.

Does anyone know what this command is called....

Also, totally unrelated, if I do a "yum update" on a fedora core 4 setup, does that mean I download most of the latest releases of packages? In other words, does that make my Fedora Core 4 installation closer to a Fedore Core 5 or 6....???
__________________
My love is in league with the fireeway...
Reply With Quote
  #2  
Old 31st January 2007, 03:49 PM
urzasrage's Avatar
urzasrage Offline
Registered User
 
Join Date: Aug 2005
Location: California
Posts: 188
Quote:
Originally Posted by chris_y2k_r1
Also, totally unrelated, if I do a "yum update" on a fedora core 4 setup, does that mean I download most of the latest releases of packages? In other words, does that make my Fedora Core 4 installation closer to a Fedore Core 5 or 6....???
Not really, just updates the programs on FC4 plus the kernel.
__________________
"I have not failed 700 times. I have not failed once. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
- Edison

It's Gnu/Linux not Linux.

Reply With Quote
  #3  
Old 31st January 2007, 06:22 PM
pianoplayer Offline
Registered User
 
Join Date: Nov 2006
Posts: 30
2 ways

Quote:
Originally Posted by chris_y2k_r1
I have a couple of questions about bash scripting. I hope I've posed this in the right forum...

Anyway, I need to find a command that will extract the integer value of a numeric variable. For example, let's say the following:

let x=4.5
echo int(x)
I am not aware of an "int" function in bash, but here are two ways to get what you want. I am assuming that you have already created a variable called x which is the number for which you want the integer part.

Method 1:

echo $x | sed 's/\..*//'

Method 2:

echo $x | awk '{print int($1)}'
Reply With Quote
  #4  
Old 31st January 2007, 06:31 PM
chris_y2k_r1 Offline
Registered User
 
Join Date: Feb 2006
Location: PA
Posts: 135
Quote:
Originally Posted by urzasrage
Not really, just updates the programs on FC4 plus the kernel.
Ok - More specifically what's the difference? Is the Kernel and it's associated programs completely different?
__________________
My love is in league with the fireeway...
Reply With Quote
  #5  
Old 31st January 2007, 06:53 PM
pianoplayer Offline
Registered User
 
Join Date: Nov 2006
Posts: 30
More information

sed and awk are utilities that date back to the early days of Unix. sed is a version of the original Unix editor ed, adapted to batch processing. awk is a programming language, suitable for one-line applications or for much larger applications. Many guides to bash programming give some introduction to these utilities; there are books available on awk.
(A very good one is Arnold Robbins, Effective Awk Programming.)
Reply With Quote
  #6  
Old 31st January 2007, 07:16 PM
chris_y2k_r1 Offline
Registered User
 
Join Date: Feb 2006
Location: PA
Posts: 135
I have the book, "Sed and Awk" where there is a drawing of two cute fuzy animals on the front, one being said and the other... Anyway, I need to read it because I see how power the functionality of these is.

Thanks PP!
__________________
My love is in league with the fireeway...
Reply With Quote
  #7  
Old 1st February 2007, 03:49 AM
RupertPupkin's Avatar
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 4,619
Quote:
Originally Posted by chris_y2k_r1
Anyway, I need to find a command that will extract the integer value of a numeric variable. For example, let's say the following:

let x=4.5
echo int(x)

Where int would be the integer value of x, if int was the actual command, then output would be 4.
Code:
x=4.5
echo "${x%.*}"
No need for sed or awk.
__________________
OS: Fedora 18 x86_64 | CPU: AMD64 3700+ 2.2GHz | RAM: 2GB PC3200 DDR | Disk: 160GB PATA | Video: ATI Radeon 7500 AGP 64MB | Sound: Turtle Beach Santa Cruz CS4630 | Ethernet: Realtek 8110SC
Reply With Quote
Reply

Tags
bash, linux, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with a bash script dan sawyer Using Fedora 5 6th July 2009 04:07 PM
Bash Script Help Jamwa Using Fedora 5 17th June 2008 05:26 PM
Convert bash script to perl script homey Programming & Packaging 1 2nd September 2006 04:24 AM


Current GMT-time: 18:56 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat