LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-30-2008, 03:31 PM   #1
mkrems
Member
 
Registered: Jan 2008
Distribution: Ubuntu
Posts: 31

Rep: Reputation: 15
using grep for numbers


i need to extract the time from some data files i am working with. at this point i can grab the line "t = 0.125" and other times from the files, but how can i grab just the number, in this case 0.125.

the current expression i am using is:
grep "t =" name_of_file.dat

thanks
 
Old 01-30-2008, 04:20 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
Hi and welcome to LQ.

How about using awk e.g.
Code:
grep "t =" name_of_file.dat | awk '{ print $3 }'
Does that help?
 
Old 01-30-2008, 05:03 PM   #3
mkrems
Member
 
Registered: Jan 2008
Distribution: Ubuntu
Posts: 31

Original Poster
Rep: Reputation: 15
yes, that does the job...thank you so much!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 08:12 AM
grep odd numbers HiOctane21 Programming 4 05-04-2007 09:12 PM
sequence of numbers, how to extract which numbers are missing jonlake Programming 13 06-26-2006 04:28 AM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 10:18 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration