Copy Limited rows from one file to another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy Limited rows from one file to another
# 1  
Old 12-17-2008
Copy Limited rows from one file to another

Hi,

The file contains 1000 of rows can you please let me know
How to copy 1-10 and 30-40 rows from one file to another.


thanks
Smilie
# 2  
Old 12-17-2008
$1 - 1000 rows file
$2 - output file
for (( i = 1; i <= 10; i++ ))
do
sed -n "$i p" $1 >> $2
done
for (( i = 30; i <= 40; i++ ))
do
sed -n "$i p" $1 >> $2
done
# 3  
Old 12-17-2008
or simply
Code:
sed -n '1,10p' INPUT > OUTPUT && sed -n '30,40p' INPUT >> OUTPUT

# 4  
Old 12-17-2008
thanks its working
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

(hard one) awk, copy matching 2 col & 10-12 rows, is it possible?

Hey guys, my first post here. I'm trying to use awk to copy all matching paragraphs from one file The file looks like this : Test Case Number 990990003099 Card Type CCCC Transaction Type Sale Entry Mode Keyed Account Number 4099562299219923 Transaction Amount 78.88 Description lorem... (2 Replies)
Discussion started by: awkawed
2 Replies

2. Shell Programming and Scripting

Moving or copying first rows and last rows into another file

Hi I would like to move the first 1000 rows of my file into an output file and then move the last 1000 rows into another output file. Any help would be great Thanks (6 Replies)
Discussion started by: kylle345
6 Replies

3. UNIX for Dummies Questions & Answers

Awk: how to copy a range of rows in GAMS environment

Hi I have a problem in using awk in GAMS. I have to copy a part of a .txt file selecting the rows between these two lines "0 / END OF TRANSFORMER DATA, BEGIN AREA DATA" "0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA" I thought of using a command like this: $onecho > area.awk... (4 Replies)
Discussion started by: Pintug
4 Replies

4. Shell Programming and Scripting

How to copy or cut specific rows from appended file with some conditions

Hi I have one file which is containing about 5000 rows and 20 columns I will just explain about my requirement here briefly with sample file, I have attached also, please help....me.. 1 28.25 36.42 5 28.26 36.42 10 28.23 36.43 15 28.22 36.43 20 28.2 36.42 25... (6 Replies)
Discussion started by: nex_asp
6 Replies

5. UNIX for Dummies Questions & Answers

merging rows into new file based on rows and first column

I have 2 files, file01= 7 columns, row unknown (but few) file02= 7 columns, row unknown (but many) now I want to create an output with the first field that is shared in both of them and then subtract the results from the rest of the fields and print there e.g. file 01 James|0|50|25|10|50|30... (1 Reply)
Discussion started by: A-V
1 Replies

6. Shell Programming and Scripting

Copy and Paste Columns in a Tab-Limited Text file

I have this text file with a very large number of columns (10,000+) and I want to move the first column to the position of the six column so that the text file looks like this: Before cutting and pasting ID Family Mother Father Trait Phenotype aaa bbb ... (5 Replies)
Discussion started by: evelibertine
5 Replies

7. UNIX for Dummies Questions & Answers

Process some limited file from a directory

Hi, I am having a directory, Having some thousand of file i want to process mean some limited files (say 6 number of files ) not the all files at a time to do that operation on them(after finish operation i'll remove and take that file back up ). Can i achieve this thing using set and shift... (2 Replies)
Discussion started by: posix
2 Replies

8. Shell Programming and Scripting

to parse (or grep) a number from a datafile and write it to tab limited file

Hi All, I have a folder that contain 100's of subfolders namely: Main folder -> GHFG - Subfoders ->10 100 234 102 345 .. .. ... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

9. UNIX for Dummies Questions & Answers

MAX file size limited to 2GB

Hi All, We are running HP rp7400 box with hpux 11iv1. Recently, we changed 3 kernel parameters a) msgseg from 32560 to 32767 b) msgmnb from 65536 to 65535 c) msgssz from 128 to 256 Then we noticed that all application debug file size increase upto 2GB then it stops. So far we did not... (1 Reply)
Discussion started by: mhbd
1 Replies

10. Shell Programming and Scripting

Capture output of program to file with limited filesize

I'm working on a script that will perform a backup, save a log of said backup and send the output to me in an email. Everything is working fine so far except that I can't figure out how to specify a maximum file size for the log file. I don't want a runaway log file jamming up the server.... (7 Replies)
Discussion started by: spectre_240sx
7 Replies
Login or Register to Ask a Question