Sponsored Content
Full Discussion: split single file into many
Top Forums Shell Programming and Scripting split single file into many Post 302196734 by aju_kup on Monday 19th of May 2008 09:39:23 AM
Old 05-19-2008
Code:
awk ' BEGIN { ctr=0;filename="FILE_" ctr}
  /^$/ { ctr= ctr + 1; filename="FILE_" ctr; next }
  {print $0 >>filename }' <file>

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

split a single sql file into multiple files

Hi,I have a single sql file containing many create table ddl's.Example: CREATE TABLE sec_afs ( rpt_per_typ_c char(1) NOT NULL, rpt_per_typ_t varchar(20) NULL, LOCK ALLPAGES go EXEC sp_primarykey 'sec_afs', rpt_per_typ_c go GRANT SELECT ON sec_afs TO developer_read_only... (5 Replies)
Discussion started by: smarter_aries
5 Replies

2. 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

3. Shell Programming and Scripting

Split a single file into several others basing on the last column

Hi folks, Happy new year. I have a file 'filename' that i wd like to split basing on the contents in the last column. The 'filename' content looks like 256772744788,9,11 256772744805,9,11 256772744792,9,11 256775543055,10,12 256782625357,9,12 256772368953,10,13 256772627735,10,13... (3 Replies)
Discussion started by: jerkesler
3 Replies

4. Shell Programming and Scripting

Split the single file lines into multiple files

Let's assume that I have a file name called ‘A' and it has 100 lines in it and would like to split these 100 lines into 4 files as specified bellow. INPUT: Input file name A 1 2 3 4 5 6 7 8 9 ........100 Output: 4 output files (x,y,z,w) File x should contains (Skip 4 lines)... (15 Replies)
Discussion started by: subbarao25
15 Replies

5. Shell Programming and Scripting

Split the a single line into two

Hi all, I wanted to split a single line into two line. For example: A/B/C 10 i want this output var1 = A/B/C var2 = 10 How do i get this. (2 Replies)
Discussion started by: ch33ry
2 Replies

6. UNIX for Dummies Questions & Answers

Split single file into n number of files

Hi, I am new to unix. we have a requirement here to split a single file into multiples files based on the number of people available for processing. So i tried my hand at writing some code as below. #!/bin/bash var1=`wc -l $filename` var2=$var1/$splitno split -l $var2 $1 Please help me... (6 Replies)
Discussion started by: quirkguy
6 Replies

7. Shell Programming and Scripting

Split single file into multiple files using pattern matching

I have one single shown below and I need to break each ST|850 & SE to separate file using unix script. Below example should create 3 files. We can use ST & SE to filter as these field names will remain same. Please advice with the unix code. ST|850 BEG|PO|1234 LIN|1|23 SE|4 ST|850... (3 Replies)
Discussion started by: prasadm
3 Replies

8. UNIX for Dummies Questions & Answers

Split files into smaller ones with 1000 hierarchies in a single file.

input file: AD,00,--,---,---,---,---,---,---,--,--,--- AM,000,---,---,---,---,---,--- AR, ,---,--,---,--- AA,---,---,---,--- AT,--- AU,---,---,--- AS,---,--- AP,---,---,--- AI,--- AD,00,---,---,---, ,---,---,---,---,---,--- AM,000,---,---,--- AR,... (6 Replies)
Discussion started by: kcdg859
6 Replies

9. Shell Programming and Scripting

Split a single file into multiple files based on a value.

Hi All, I have the sales_data.csv file in the directory as below. SDDCCR; SOM ; MD6546474777 ;05-JAN-16 ABC ; KIRAN ; CB789 ;04-JAN-16 ABC ; RAMANA; KS566767477747 ;06-JAN-16 ABC ; KAMESH; A33535335 ;04-JAN-16 SDDCCR; DINESH; GD6674474747 ;08-JAN-16... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies

10. Shell Programming and Scripting

Need to split string on single quote as delimiter

I have a variable that contains the following string: FPATH=-rw-rw-r-- 1 user1 dba 0 Aug 7 13:14 /app/F11.3/app/cust/exe/filename1.exe' -rw-rw-r-- 1 user1 dba 0 Aug 19 10:09 /app/app/F11.3/app/cust/sql/33211.sql' -rw-r--r-- 1 user1 dba 0 Aug 6 17:20 /app/F11.2/app/01/mrt/file1.mrt' I... (7 Replies)
Discussion started by: mohtashims
7 Replies
PMC(9)							   BSD Kernel Developer's Manual						    PMC(9)

NAME
pmc, pmc_get_num_counters, pmc_get_counter_type, pmc_save_context, pmc_restore_context, pmc_enable_counter, pmc_disable_counter, pmc_counter_isrunning, pmc_counter_isconfigured, pmc_configure_counter, pmc_get_counter_value, pmc_accumulate, pmc_alloc_kernel_counter, pmc_free_kernel_counter, pmc_start_profiling, pmc_stop_profiling, PMC_ENABLED -- Hardware Performance Monitoring Interface SYNOPSIS
#include <sys/pmc.h> int pmc_get_num_counters(void); int pmc_get_counter_type(int ctr); void pmc_save_context(struct lwp *l); void pmc_restore_context(struct lwp *l); int pmc_enable_counter(struct lwp *l, int ctr); int pmc_disable_counter(struct lwp *l, int ctr); int pmc_counter_isrunning(struct lwp *l, int ctr); int pmc_counter_isconfigured(struct lwp *l, int ctr); int pmc_configure_counter(struct lwp *l, int ctr, struct pmc_counter_cfg *cfg); int pmc_get_counter_value(struct lwp *l, int ctr, int flags, uint64_t *pval); int pmc_accumulate(struct lwp *l_parent, struct lwp *l_exiting); int pmc_alloc_kernel_counter(int ctr, struct pmc_counter_cfg *cfg); int pmc_free_kernel_counter(int ctr); int pmc_start_profiling(int ctr, struct pmc_counter_cfg *cfg); int pmc_stop_profiling(int ctr); int PMC_ENABLED(struct lwp *l); DESCRIPTION
Provides a machine-independent interface to the hardware performance counters which are available on several CPU families. The capabilities of these counters vary from CPU to CPU, but they basically count hardware events such as data cache hits or misses, branches taken, branched mispredicted, and so forth. Some can interrupt the processor when a certain threshold has been reached. Some can count events in user space and kernel space independently. The pmc interface is intended to allow monitoring from within the kernel as well as monitoring of userland applications. If the hardware can interrupt the CPU in a specific implementation, then it may also be used as a profiling source instead of the clock. IMPLEMENTATION NOTES
All function calls in this interface may be defined as cpp(1) macros. If any function is not implemented as a macro, its prototype must be defined by the port-specific header <machine/pmc.h>. Counters are numbered from 0 to N-1 where N is the number of counters available on the system (see pmc_get_num_counters() below). Upon a process fork, implementations must o Zero performance counters for the new process, and o Inherit any enabled performance counters. DATA TYPES
Each implementation must specify two new types: pmc_evid_t An integer type which can contain the event IDs for a given processor. pmc_ctr_t An integer type defining the value which may be contained in a given counter register. Counters are configured with the struct pmc_counter_cfg. This structure is defined as struct pmc_counter_cfg { pmc_evid_t event_id; pmc_ctr_t reset_value; uint32_t flags; }; flags are currently unused. FUNCTIONS
pmc_get_num_counters(void) Returns the number of counters present on the current system. Valid values for ctr in the interface entry points below are from zero to one less than the return value from this function. pmc_get_counter_type(int ctr) Returns an implementation-dependent type describing the specified counter. If ctr is specified as -1, returns a machine-dependent type describing the CPU or counter configuration. For example, on an ia32 architecture, it may distinguish between 586-, 686-, and K7-style counters. pmc_save_context(struct lwp *l) Saves the PMC context for the current process. This is called just before cpu_switch(9). If there is kernel PMC state, it must be maintained across this call. pmc_restore_context(struct lwp *l) Restores the PMC context for the current process. This is called just after cpu_switch(9) returns. If there is kernel PMC state, it must be maintained across this call. pmc_enable_counter(struct lwp *l, int ctr) Enables counter ctr for the specified process. The counter should have already been configured with a call to pmc_configure_counter(). This starts the counter running if it is not already started and enables any interrupts, as appropriate. pmc_disable_counter(struct lwp *l, int ctr) Disables counter ctr for the specified process. This stops the counter from running, and disables any interrupts, as appropriate. pmc_counter_isrunning(struct lwp *l, int ctr) Returns non-zero if the specified counter in the specified process is running or if the counter is running in the kernel. pmc_counter_isconfigured(struct lwp *l, int ctr) Returns non-zero if the specified counter in the specified process is configured or if the counter is in use by the kernel. pmc_configure_counter(struct lwp *l, int ctr, struct pmc_counter_cfg *cfg) Configures counter ctr according to the configuration information stored in cfg. pmc_get_counter_value(struct lwp *l, int ctr, int flags, uint64_t *pval) Returns the value of counter ctr in the space pointed to by pval. The only recognized flag is PMC_VALUE_FLAGS_CHILDREN which speci- fies that the returned counts should be accumulated values for any exited child processes. pmc_accumulate(struct lwp *l_parent, struct lwp *l_exiting) Accumulates any counter data from the exiting process p_exiting into the counters for the parent process p_parent. pmc_alloc_kernel_counter(int ctr, struct pmc_counter_cfg *cfg) Allocates counter ctr for use by the kernel and configures it with cfg. pmc_free_kernel_counter(int ctr) Returns counter ctr to the available pool of counters that may be used by processes. pmc_start_profiling(int ctr, struct pmc_counter_cfg *cfg) Allocates counter ctr for use by the kernel for profiling and configures it with cfg. pmc_stop_profiling(int ctr) Stops profiling with counter ctr. PMC_ENABLED(struct lwp *l) Returns non-zero if the given process or the kernel is using the PMC at all. SEE ALSO
pmc(1), pmc_control(2), pmc_get_info(2) HISTORY
The pmc interface appeared in NetBSD 2.0. AUTHORS
The pmc interface was designed and implemented by Allen Briggs for Wasabi Systems, Inc. Additional input on the pmc design was provided by Jason R. Thorpe. BSD
May 14, 2010 BSD
All times are GMT -4. The time now is 07:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy