Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Split file based on number of blank lines Post 302895651 by Yoda on Tuesday 1st of April 2014 03:13:38 PM
Old 04-01-2014
Quote:
Originally Posted by Pratik4891
Thanks Yoda,could you please explain the solution ?
Sure, for each non-zero number of field records, the program construct a variable s with value separated by RS (newline by default)
Code:
s = s ? s RS $0 : $0

Once a zero number of field record is encountered and s value is not null, it stores the record as key into an associative array: A

Finally in the END rule, the program writes each key in the array to a file.
This User Gave Thanks to Yoda For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I get an if statement to execute based on number of lines in a file?

I need to have an if statement in a script to run if there are certain processes running. Easiest way I can see to do this is to run a ps and grep the results based on what I am looking for: $ ps -ef | grep wtrs --- webtrend 5046 1 0 May 12 ? 0:28 /webtrends/versions/6.1/wtrs_ui... (6 Replies)
Discussion started by: LordJezo
6 Replies

2. Shell Programming and Scripting

Split File Based on Line Number Pattern

Hello all. Sorry, I know this question is similar to many others, but I just can seem to put together exactly what I need. My file is tab delimitted and contains approximately 1 million rows. I would like to send lines 1,4,& 7 to a file. Lines 2, 5, & 8 to a second file. Lines 3, 6, & 9 to... (11 Replies)
Discussion started by: shankster
11 Replies

3. Shell Programming and Scripting

Scripting help: Split a file into equal number of lines.

Experts, I have a file datafile.txt that consists of 1732 Line, I want to split the file into equal number of lines with 10 file. (The last file can have 2 line extra to match 1732) Please advise how to do that, Thanks in advance.. (2 Replies)
Discussion started by: rveri
2 Replies

4. Shell Programming and Scripting

Split single file into multiple files based on the number in the column

Dear All, I would like to split a file of the following format into multiple files based on the number in the 6th column (numbers 1, 2, 3...): ATOM 1 N GLY A 1 -3.198 27.537 -5.958 1.00 0.00 N ATOM 2 CA GLY A 1 -2.199 28.399 -6.617 1.00 0.00 ... (3 Replies)
Discussion started by: tomasl
3 Replies

5. Shell Programming and Scripting

Script to split files based on number of lines

I am getting a few gzip files into a folder by doing ftp to another server. Once I get them I move them to another location .But before that I need to make sure each gzip is not more than 5000 lines and split it up . The files I get are anywhere from 500 lines to 10000 lines in them and is in gzip... (4 Replies)
Discussion started by: gubbu
4 Replies

6. Shell Programming and Scripting

split a csv file into specified number of files (not lines)

hi, i really need it ...it's not simple to explain but as it's part of a crontab i can't split the file manually...and the file can change every day so the lines are not a good base. example: how to split 1 csv file in 15 files? thank you very much regards :b: (4 Replies)
Discussion started by: 7stars
4 Replies

7. UNIX for Dummies Questions & Answers

Command to split the files based on the number of lines in it

Hello Friends, Can anyone help me for the below requirement. I am having a file called Input.txt. My requirement is first check the count that is wc -l input.txt If the result of the wc -l Input.txt is less than 10 then don't split the Input.txt file. Where as if Input.txt >= 10 the split... (12 Replies)
Discussion started by: malaya kumar
12 Replies

8. Shell Programming and Scripting

How to split a file based on pattern line number?

Hi i have requirement like below M <form_name> sdasadasdMklkM D ...... D ..... M form_name> sdasadasdMklkM D ...... D ..... D ...... D ..... M form_name> sdasadasdMklkM D ...... M form_name> sdasadasdMklkM i want split file based on line number by finding... (10 Replies)
Discussion started by: bhaskar v
10 Replies

9. Shell Programming and Scripting

Split File based on number of rows

Hi I have a requirement, where i will receive multiple files in a folder (say: /fol1/fol2/). There will be at least 14 to 16 files. The size of the files will different, some may be 80GB or 90GB, some may be less than 5 GB (and the size of the files are very unpredictable). But the names of the... (10 Replies)
Discussion started by: kpk_ds
10 Replies

10. UNIX for Beginners Questions & Answers

Split file into multiple files based on empty lines

I am using below code to split files based on blank lines but it does not work. awk 'BEGIN{i=0}{RS="";}{x="F"++i;}{print > x;}' Your help would be highly appreciated find attachment of sample.txt file (2 Replies)
Discussion started by: imranrasheedamu
2 Replies
stl_key(5)							File Formats Manual							stl_key(5)

Name
       stl_key - setld kit manufacturing key file

Description
       The manufacturing key files are used by the software kitting program in producing software distribution packages in format.

       A  key file has a global data section and a subset descriptor section. The sections are separated by a line that is empty except for the %%
       character sequence.

       The global section contains the product level attributes of the product. Comments are permitted in this section. They begin with the number
       sign  (#)  character and end at the next newline character.  Attributes are specified by giving the attribute key, an equal sign (=), and a
       value for the attribute.  There must be no white space surrounding the equals sign (=). There are five attributes that must be present with
       non-null values. These are NAME, CODE, VERS, MI, and ROOT.  An explanation of each of the attributes follows:

	  NAME	    The name of the product. The value for NAME is a string of up to 40 characters.

	  CODE	    The 3-character product code for the product, for example, ULT.

	  VERS	    The 3-digit version code for the product, for example, 040.

	  MI	    The pathname of the master inventory file for the product.

	  ROOT	    A  flag with values of 0 or 1. It is used to determine if a ROOT image checksum should be computed for the product image file.
		    There is no ROOT image in any product other than ULTRIX. Set it to 0.

	  RXMAKE    A flag with values of 0 or 1. Setting it to 0 suppresses the manufacture of subset images for distribution on RX50	diskettes.
		    Omitting this attribute from the key file will cause the program to assume a default value of 1. Digital recommends setting it
		    to 0.

	  COMPRESS  A flag with values of 0 or 1. Setting it to 1 causes the subset images to be compressed  using  the  utility,  thereby  saving
		    space  on the distribution media. Setting it to 0 suppresses compression. Omitting this attribute from the key file will cause
		    the program to assign a default value of 0.

       The subset descriptor section contains one subset descriptor for each subset in the product. There is one subset  descriptor  per  line	in
       this section and comments are not permitted.

       A  subset  descriptor  contains subset-specific attributes in four fields separated by TAB (CTRL/I) characters. A description of each field
       follows:

	  SUBSET    This field contains the name of the subset being described by the descriptor. The subset name is composed of the product code,
		    name and version code.

	  DEPENDENCIES
		    A list of subsets on which the described subset depends. If there are no such subsets, the period character (.) is used.  Mul-
		    tiple subset dependencies are separated by a vertical bar character (|).

	  FLAGS     A subset flags value. This is an integer. Bit 0 is used to mark the subset as irremovable. If bit 0 is set, can  never  delete
		    the  subset. Bit 1 is used to mark the subset as optional, otherwise it is mandatory and must be installed from the media when
		    encountered by

	  DESCRIPTION
		    This is a description of the subset in 40 or fewer characters.  It is used in the menu that presents to a user installing  the
		    software. If spaces are desired in this field, the field must be enclosed in single quotes.

       The subset descriptors must be listed in the order in which the subsets are installed by

Restrictions
       The required attributes and default values are not optimal.

       Comments in the subset descriptor section will cause serious problems when encountered by the program.

       TAB formatting in the subset descriptors is tightly enforced by the program.

Examples
       This is an example key file:
	   #	 ULW400.k -
	   #	      ULTRIX WS V4.0 Server 2/2 (VAX) Mfg Key File
	   #
	   #	 "@(#)ULW400.k	2.2 (ULTRIX) 4/12/89"
	   #
	   #	 000  02-mar-1989    ccb
	   #	 Copy from V2.0 (VAX) Sources
	   #	 Revision update for V4.0

	   #% PRODUCT-LEVEL ATTRIBUTES
	   NAME='ULTRIX Worksystem Software V4.0'
	   CODE=UWS
	   VERS=400
	   MI=ULT400.mi
	   ROOT=0
	   RXMAKE=0
	   COMPRESS=1

	   #% SUBSET-LEVEL ATTRIBUTES
	   %%
	   UWSX11400  ULTINET400     0	  'X11/DECwindows User Environment'
	   UWSFONT400 UWSX11400 0    'X11/DECwindows 75dpi Fonts'
	   UWSFONT15400    .	2    'X11/DECwindows 100dpi Fonts'
	   UWSDECW400 .    2	'Optional DECwindows Applications'
	   UWSXDEV400 ULTPGMR400     2	  'Worksystems Development Software'
	   UWSMAN400  ULTDCMT400     2	  'UWS Manual Pages'

See Also
       kits(1), stl_comp(5), stl_ctrl(5), stl_image(5), setld(8)
       Guide to Preparing Software for Distribution on ULTRIX Systems

																	stl_key(5)
All times are GMT -4. The time now is 06:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy