how to cut selected 10k lines continuosly


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to cut selected 10k lines continuosly
# 1  
Old 09-04-2008
how to cut selected 10k lines continuosly

I have a source file having 20lacs lines i want to cut first 1 lac lines from source file and redirect to other file (i.e after redirecting the output to other file the source file should have only 19 lacs count ). Pls help me in getting solution.

Thanks in advance.
# 2  
Old 09-04-2008
Can you explain what a lac is and how to recognize the begin and end of the lac you want to (re)move?

Regards
# 3  
Old 09-04-2008
Hi franklin thanks for early reply,what i mean to say is i have a file having 20 million lines if i want to cut 1 million lines from source file how can i do that( i.e after cutting 1 million lines from source file the source file should have only 19 million lines pls help.
# 4  
Old 09-04-2008
The first million lines goes to file1 and the remaining lines to file2:

Code:
awk 'NR<1000001{print $0 > "file1";next}{print $0 > "file2"}' file

Regards
# 5  
Old 09-04-2008
Is there any possibility that i can cut first 1million count from source
file and append directly to another file for example like this

cut -10000 filename > file2 (this is just example to understand my requirement)
# 6  
Old 09-04-2008
Pls reply on the above query.
# 7  
Old 09-04-2008
It's not allowed to bump up questions! Please read the rules.

Have you tried the solution above? Maybe you can also use the commands head and tail. Read the regarding manpages.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting selected lines in a file

Hi Guys , I have two files say a1 and a2 having following contents a1 dag wfd a2 dag wfd chire hcm I want to delete only the lines in a2 which are in a1 and final output of a2 should be a2 chire hcm (6 Replies)
Discussion started by: Pradeep_1990
6 Replies

2. Shell Programming and Scripting

Selected matching lines

two files: one with the line number only, and the 2nd one with line number and content, as following: line_file.txt 1 3 5 9 23 30 content_file.txt 1|we are the world|good|great 2|easily do this by highlighting you|easily do this by highlighting you|easily do this by highlighting... (2 Replies)
Discussion started by: dtdt
2 Replies

3. Shell Programming and Scripting

Delete selected lines

hi Gurus, I have a source file with more than 10 columns ( not fixed ) I want to delete all the lines on the following condition 1) where i have first column as "UPDATE PLAN ADD RATE SCHEDULE" and fourth column as null awk '($1=="UPDATE PLAN ADD RATE SCHEDULE" && $4=="") {print $0}'... (5 Replies)
Discussion started by: r_t_1601
5 Replies

4. Shell Programming and Scripting

finding least out of selected lines

Hello, I have a file, which looks like: I want to print the row containg "PRO" in second column after comparing and finding the minimum value of fifth column present in all "PRO". and likewise for every other string present in second column. I am using : filename=list... (2 Replies)
Discussion started by: CAch
2 Replies

5. Shell Programming and Scripting

How to cut selected lines from command output

Hi guys, I need to cut the first 12 system processes from the command ps -A. I know that the cut command forms part of the pipeline but can't understand how to cut the first 12 lines and later display them on standard output. Please help! Many thanks, Jared. (3 Replies)
Discussion started by: jjb1989
3 Replies

6. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

7. Shell Programming and Scripting

Process selected lines

I have an if statement where I state that if there are more than one records (lines) found containing a string in a file, then it enters into a while loop to use each line for as many lines as there are and then stop. Trouble is, I can't figure out how to move to the next instance of each line. ... (2 Replies)
Discussion started by: derekphl
2 Replies

8. UNIX for Dummies Questions & Answers

Copy selected lines in vim

Hi, I am looking to copy selected lines from a file using the vim editor. I have looked up a few resources and they have suggested to use this- Type mk Type: "ay'k (double quotes, <register name from a-z>, <y-yank single quote, k You can paste those lines wherever you want with "ap I tried... (7 Replies)
Discussion started by: coolavi
7 Replies

9. UNIX for Dummies Questions & Answers

extracting selected few lines through perl

How can I extract few lines(like 10 to 15, top 10 and last 10) from a file using perl. I do it with sed, head and tail in unix scripting. I am new to perl. Appreciate your help. (2 Replies)
Discussion started by: paruthiveeran
2 Replies

10. Shell Programming and Scripting

print selected lines

Hi everybody: I try to print in new file selected lines from another file wich depends on the first column. I have done a script like this: lines=( "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "21" "31" "41" "51" "55" "57" "58" ) ${lines} for lines in ${lines} do awk -v ... (6 Replies)
Discussion started by: tonet
6 Replies
Login or Register to Ask a Question