LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2011, 02:58 PM   #1
DuskFall
LQ Newbie
 
Registered: Aug 2011
Posts: 18

Rep: Reputation: Disabled
Grab line based on string


Ok so i have a file with a lot of lines in it, and i would like to grab just the line that contains a string i've specified in a variable... Let me know if you want a sample of the file. Thanks in advance
 
Old 08-09-2011, 03:02 PM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

A sample is always the best starting point just to avoid mistakes and misunderstandings. Talking about misunderstandings, is this question the same as you asked in this thread which you marked as solved, or is it different. If different please specify how and why so that we're clear on that. If it's different in the sense that you now want to save the entire line instead of a value between tags, then have a look at my first post in that thread on how you could use grep.

Kind regards,

Eric
 
Old 08-09-2011, 03:07 PM   #3
DuskFall
LQ Newbie
 
Registered: Aug 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Sorry, my mistake... thank you
 
Old 08-09-2011, 03:08 PM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

No problem. You marked the thread as solved. Does that mean that the reference to grep I posted is what you were looking for?

Kind regards,

Eric
 
1 members found this post helpful.
  


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
Filter through line/s to grab specific fields/data in the line with example shayno90 Linux - Newbie 11 10-14-2009 12:51 PM
Grab time from string kram66 Programming 1 05-10-2009 10:23 PM
grab the line below a blank line and the line above the next blank line awk or perl? Pantomime Linux - General 7 06-26-2008 09:13 AM
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 09:22 AM


All times are GMT -5. The time now is 03:01 PM.

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