There are two ways to write error-free programs; only the third works.
Alan J. Perlis
I am doing a startup!
Cross-browser testing from your browser!
I have written my fourth book!
Be faster than Larry Wall at command line!
You're viewing a comment by Rama and its responses.
Hi there Peter!
I just bought your Awk and Sed book and I think they are fantastic. I went through the entire Awk book and learnt a lot in a very short time. There is however a "specific" question which I was looking an answer for and did not find any. I was hoping you could give me some insight into the same.
I have a text file which has a single column of numbers which are not serially ordered (e.g, 1,4,6,9,11,27 and so on...) A few hundred of them (n=768). These are actually the line numbers of a very BIG file which has 50,000 lines of text.
What I would like to do is for either Awk or Sed to read the numbers in the text file and extract the full contents of each of the numbered line from the BIG file.
Is there a direct way to do this in either Awk or Sed? Or do I have to rely on a bash script to first read the text file, create and array and then load the array into a awk one liner one at a time and extract that particular line from the Big file?
A lot of the examples were either serial numbers i.e, lines 8 through 12 or something like that. None of the examples were random lines like the issue I am facing.
I would hugely grateful for any pointers here.
(why do I need your e-mail?)
It would be nice if you left your e-mail address. Sometimes I want to send a private message, or just thank for the great comment. Having your e-mail really helps.
I will never ever spam you.
(Your twitter handle, if you have one.)
* use <pre>...</pre> to insert a plain code snippet.
* use <pre lang="lang">...</pre> to insert a syntax highlighted code snippet.
For example, <pre lang="python">...</pre> will insert Python highlighted code.
* use <code>...</code> to highlight a variable or a single shell command.
* use <a href="url" nospam>title</a> to insert links.
<a href="url" nospam>title</a>
* use other HTML tags, such as, <b>, <i>, <blockquote>, <sup>, <sub> for text formatting.
Type the word "lcd_257": (just to make sure you're a human)
Please preview the comment before submitting to make sure it's OK.
Peter Krumins' blog about programming, hacking, software reuse, software ideas, computer security, browserling, google and technology.
Reach me at:
Or meet me on:
Subscribe through an RSS feed:
(what is rss?)
Subscribe through email:
Enter your email address:
Delivered by FeedBurner
I love to read science books. They make my day and I get ideas for awesome blog posts, such as Busy Beaver, On Functors, Recursive Regular Expressions and many others.
Take a look at my Amazon wish list, if you're curious about what I have planned reading next, and want to surprise me. :)
See all top articles
See all downloads
See more detailed list of recent articles
See more detailed category information
See more detailed list of all articles