Extract known lines


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extract known lines
# 1  
Old 09-16-2004
Extract known lines

Hi all,

I have a text file of 143 lines. The I don't want all lines but want to retain line format.

How can I extract lines 34, 65, 68, 70 (plus 7 others) easliy?

I have found some example head/tail n lines and some sed -n examples that have been shown for single line or mass consecutive extractions. What i would idealy like is a one liner that I give the line numbers to extract.

Any hints or examples would be great.

Cheers and beers,
Neil
# 2  
Old 09-16-2004
I'd actually use sed
Code:
sed -n '5p;10p;20p;51p' testfile

To extract lines 5, 10, 20 and 51 from testfile.

Cheers
ZB
# 3  
Old 09-16-2004
Sweat.....job done.

Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract lines that appear twice

I have a text file that looks like this : root/user/usr1/0001/abab1* root/user/usr1/0001/abab2* root/user/usr1/0002/acac1* root/user/usr1/0002/acac2* root/user/usr1/0003/adad1* root/user/usr1/0004/aeae1* root/user/usr1/0004/aeae2* How could I code this to extract just the subjects... (9 Replies)
Discussion started by: LeftoverStew
9 Replies

2. Shell Programming and Scripting

ksh sed - Extract specific lines with mulitple occurance of interesting lines

Data file example I look for primary and * to isolate the interesting slot number. slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'` Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk... (2 Replies)
Discussion started by: popeye
2 Replies

3. Shell Programming and Scripting

Extract particular lines from a file

Hi all, I have a file with many records with information as given below ID A16L2_HUMAN Reviewed; 619 AA. AC Q8NAA4; A5PL30; B2RPK5; Q658V4; Q6PID3; Q8NBG0; DT 20-MAY-2008, integrated into UniProtKB/Swiss-Prot. DT 20-MAY-2008, sequence version 2. DT ... (1 Reply)
Discussion started by: kaav06
1 Replies

4. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

5. Shell Programming and Scripting

Extract the lines between two dates

Dear experts I am new bee to scripting... Pl. help me getting the lines between two strings. I am getting the oracle sql output as below. and would like to get the time from system date compare with the date in sql output file and extract the lines. if system time is 2012-07-01 19:15:00 get... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

6. UNIX for Dummies Questions & Answers

Extract lines with specific words with addition 2 lines before and after

Dear all, Greetings. I would like to ask for your help to extract lines with specific words in addition 2 lines before and after these lines by using awk or sed. For example, the input file is: 1 ak1 abc1.0 1 ak2 abc1.0 1 ak3 abc1.0 1 ak4 abc1.0 1 ak5 abc1.1 1 ak6 abc1.1 1 ak7... (7 Replies)
Discussion started by: Amanda Low
7 Replies

7. Shell Programming and Scripting

Extract some lines from one file and add those lines to current file

hi, i have two files. file1.sh echo "unix" echo "linux" file2.sh echo "unix linux forums" now the output i need is $./file2.sh unix linux forums (3 Replies)
Discussion started by: snreddy_gopu
3 Replies

8. Shell Programming and Scripting

Script to extract certain lines

Hi I have a text file with the following information: # List 1 (first header) test 1 test 2 test 3 ... # Trials (second header) round 1 run 5 ... and so on I want to create a script, which based on some criterias with return only the list of lines between the header. I... (9 Replies)
Discussion started by: nimo
9 Replies

9. UNIX for Dummies Questions & Answers

extract lines from data

I have a file that looks like this: >cel-miR-35 MIMAT6 C eles le UCACCGGGUGGAAACUAGCAGU >hsa-let-7a MI062 H sa UGAGGUAGUAGGUUGUAUAGUU >cel-miR-36 M007 Ca ele UCACCGGGUGAAAAUUCGCAUG >hsa-let-7b MI63 Hmo sns le UGAGGUAGUAGGUUGUGUGGUUI would like to extract all the lines that start with... (7 Replies)
Discussion started by: jdhahbi
7 Replies

10. Shell Programming and Scripting

extract the lines

Hi, I have a text file with 15 columns and i want to extract those lines of which 7th column is ABCD. I think we can do this using awk but could not frame the command. Please help. TIA Prvn (2 Replies)
Discussion started by: prvnrk
2 Replies
Login or Register to Ask a Question