cut a number of lines out of a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cut a number of lines out of a file
# 1  
Old 12-08-2005
cut a number of lines out of a file

Hi,

I have a text file contaning around 150 lines, each line is a hostname.
I want to read 4 lines/hostnames and save those 4 lines to a seperate file.
say the big file is /files/bigfile and I want to have a lot of files in /files named
/files/smallfile.1 , /files/smallfile.2 and so on...

I have no idea how to do this

Thanks
# 2  
Old 12-09-2005
Code:
awk '{print >("smallfile" int((NR+3)/4))}' bigfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Number of Lines in a file

Hi All, This is my Scenario: I wanted to check if a particular name or pattern is present in a file based of that rest of the program should proceed. I want to print '0' if no matching found. v_File_Count=`grep -i "$v_Name_Pattern" $File_Path/Master_File_List.txt | wc -l` The above command... (5 Replies)
Discussion started by: TechGyaann
5 Replies

2. Shell Programming and Scripting

Number of lines in file

How can I find the number of lines in a file excluding lines starting with #? (4 Replies)
Discussion started by: kristinu
4 Replies

3. Shell Programming and Scripting

cut lines from log file and save it another file

Dears, i want cut the lines from a log file. Example of the log file as follows.. May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMDeliverContrUtil isDeliverSM FINE: May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMUtil addSysUpMsgLog INFO: . The message content... (1 Reply)
Discussion started by: tonypalokkaran
1 Replies

4. UNIX for Dummies Questions & Answers

cut particular lines from a file

how can I cut out partiluar lines like from line 233 to 347 ? any idea? (2 Replies)
Discussion started by: kvok
2 Replies

5. AIX

How to cut a flat file according to a certain number of characters?

hello everybody i am looking for a shell to cut a flat file (with a long unique line) according to a certain number of characters and redirect every result to an output file. here is an example MyFile : 12 3 456 12 3 456 12 3 456 ..... and i took every 9-characters including BLANKS... (6 Replies)
Discussion started by: fastlane3000
6 Replies

6. Shell Programming and Scripting

Number lines of file and assign variable to each number

I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later. Ex. 1 some data 2 something else 3 more stuff which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies

7. Shell Programming and Scripting

cut lines in a file.

Hi Everyone, I have a file a.txt, inside is Mon Jul 20 00:05:07 2009 12 Mon Jul 20 00:05:08 2009 1 The output should be a.txt, inside is 00:05:07 12 00:05:08 1 My method is `cat a.txt | cut -f4,6 -d' ' > a.txt.tmp;mv -rf a.txt.tmp a.txt`; Is any good way to do this? like perl... (5 Replies)
Discussion started by: jimmy_y
5 Replies

8. Shell Programming and Scripting

How to find number of lines in a file

Hi How do I find number of lines of a file? Below commands returned 0. But, the file is showing 20 lines when I open it in editplus tool. Each line contains 601 columns. Please advise I want to incorporate some word at the begining of each of those 20 lines -Somesh $ wc -l <... (2 Replies)
Discussion started by: somesh_p
2 Replies

9. Shell Programming and Scripting

total number of lines in a file

Hi , How about find the total number of lines in a file ? How can i do that with the "grep" command ? (9 Replies)
Discussion started by: Raynon
9 Replies

10. Shell Programming and Scripting

cut 11 lines from a file

All, I have a file that I want to read, cut 12 lines and direct into a new file, and continue to do this until I reach the EOF. How do I do it? can I use cat or read to do this? the file is formated with repetitive output consisting of these 12 lines date: <Timestamp> dev_id: <device ID>... (7 Replies)
Discussion started by: turk22
7 Replies
Login or Register to Ask a Question