|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extracting lines from a text file based on another text file with line numbers
Hi,
I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Assuming that your
lines_file contains each line number on a separate line (and that you don't want to consider duplicate line numbers, if they exist): Code:
awk 'FNR==NR{a[$1];next}FNR in a' lines_file data_file |
| The Following User Says Thank You to elixir_sinari For This Useful Post: | ||
evelibertine (12-11-2012) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extracting Multiple Lines from a Text File | MrDumbQuestion | Shell Programming and Scripting | 4 | 12-20-2011 09:10 AM |
| Extracting rows from a text file based on the first column | evelibertine | UNIX for Dummies Questions & Answers | 1 | 09-19-2011 08:15 PM |
| Extracting rows from a text file based on the first column | evelibertine | UNIX for Dummies Questions & Answers | 1 | 08-17-2011 05:53 PM |
| extracting unique lines from text file | soliberus | Shell Programming and Scripting | 3 | 08-22-2008 10:18 AM |
| Extracting data from text file based on configuration set in config file | suparnbector | Shell Programming and Scripting | 3 | 08-10-2007 02:25 AM |
|
|