Sponsored Content
Top Forums Shell Programming and Scripting How to split a data file into separate files with the file names depending upon a column's value? Post 302558748 by nithins007 on Sunday 25th of September 2011 06:56:35 AM
Old 09-25-2011
Question How to split a data file into separate files with the file names depending upon a column's value?

Hi,
I have a data file xyz.dat similar to the one given below,
Code:
2345|98|809||x|969|0
2345|98|809||y|0|537
2345|97|809||x|544|0
2345|97|809||y|0|651
9685|98|809||x|321|0
9685|98|809||y|0|357
9685|98|709||x|687|0
9685|98|709||y|0|234
2315|98|809||x|564|0
2315|98|809||y|0|537
2315|98|809||x|523|0
2315|98|809||y|0|535

I need to split the file into seperate file with the condition that :
1) All the rows which has the same value in column 1 should be in one file.
2) The name of the file should be starting with the column 1's value.

Code:
ie:
2345_xyz.dat should be created and it should contain only the below data:
2345|98|809||y|0|537
2345|97|809||x|544|0
2345|97|809||y|0|651

9685_xyz.dat should be created and it should contain only the below data:
9685|98|809||x|321|0
9685|98|809||y|0|357
9685|98|709||x|687|0
9685|98|709||y|0|234

2315_xyz.dat should be created and it should contain only the below data:
2315|98|809||x|564|0
2315|98|809||y|0|537
2315|98|809||x|523|0
2315|98|809||y|0|535

Also the main data file xyz.dat should not be removed.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

split file depending on content

Hi, I have a file which contains records of data. I need to split the file into multiple files depending upon the value of last field. How do i read the last field of each record in the file??? Regards, Chaitrali (4 Replies)
Discussion started by: Chaitrali
4 Replies

2. Shell Programming and Scripting

Split file into multiple files depending upon first 4 digits

Hi All, I have a file like below: 1016D"ddd","343","1299" 1016D"ddd","3564","1299" 1016D"ddd","3297","1393" 1016D"ddd","32989","1527" 1016D"ddd","346498","1652" 2312D"ddd","3269","1652" 2312D"ddd","328","1652" 2312D"ddd","2224","2100" 3444D"ddd","252","2100" 3444D"ddd","2619","2100"... (4 Replies)
Discussion started by: deepakgang
4 Replies

3. Shell Programming and Scripting

Using AWK to separate data from a large XML file into multiple files

I have a 500 MB XML file from a FileMaker database export, it's formatted horribly (no line breaks at all). The node structure is basically <FMPXMLRESULT> <METADATA> <FIELD att="............." id="..."/> </METADATA> <RESULTSET FOUND="1763457"> <ROW att="....." etc="...."> ... (16 Replies)
Discussion started by: JRy
16 Replies

4. UNIX for Dummies Questions & Answers

How to separate a single column file into files of the same size (i.e. number of rows)?

I have a text file with 1,000,000 rows (It is a single column text file of numbers). I would like to separate the text file into 100 files of equal size (i.e. number of rows). The first file will contain the first 10,000 rows, the second row will contain the second 10,000 rows (rows 10,001-20,000)... (2 Replies)
Discussion started by: evelibertine
2 Replies

5. Shell Programming and Scripting

find specific file names and execute a command depending on file's name

Hi, As a newbie, I'm desperate ro make my shell script work. I'd like a script which checks all the files in a directory, check the file name, if the file name ends with "extracted", store it in a variable, if it has a suffix of ".roi" stores in another variable. I'm going to use these two... (3 Replies)
Discussion started by: armando110
3 Replies

6. Shell Programming and Scripting

Divide data with specific column values into separate files

hello! i need a little help from you :) ... i need to split a file into separate files depending on two conditions using scripting. The file has no delimiters. The conditions are col 17 = "P" and col 81 = "*", this will go to one output file; col 17 = "R" and col 81 = " ". Here is an example. ... (3 Replies)
Discussion started by: chanclitas
3 Replies

7. Shell Programming and Scripting

How to Split File to 2 depending on condition?

Hi , cat myfile.txt ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.22.11 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.2.50 ! 3100.2.22.11 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 !... (6 Replies)
Discussion started by: OTNA
6 Replies

8. Shell Programming and Scripting

Split file depending on Column Value

Hi , my file look likes below , cat file.csv 12/09/2014,50,5,0,300 12/09/2014, ,5,0,300 12/09/2014,50,,,300 i need to split file , the first one contains values (2nd column is 50 , 3rd and fourth column is null ) the second file contains all others firstfile ... (2 Replies)
Discussion started by: ubaisalih
2 Replies

9. UNIX for Dummies Questions & Answers

Split larger files into smaller ones with Column names

Hi, I have one large files of 100000 rows with header column. Eg: Emp Code, Emp Name 101,xxx 102,YYY 103,zzz ... ... I want to split the files into smaller files with only 30000 rows each..File 1,2 and 3 must have 30000 rows and file 4 must contain 10000 rows. But the column... (1 Reply)
Discussion started by: Nivas
1 Replies

10. Shell Programming and Scripting

How to separate data coming in one column of CSV file?

I am running an ISQL command on Sybase DB and getting output of a query in an CSV file. The issue is that all the data comes in to the same column, i want them to be separated in different columns. SQL_COMMAND=command.sql file=file.txt formatFile=formatFile.txt report=report.csv echo... (1 Reply)
Discussion started by: Sharma331
1 Replies
show(1m)																  show(1m)

NAME
show - Displays current information about the DTS entity SYNOPSIS
dtscp show attribute-group | attribute-name ARGUMENTS
The name of an attribute group or individual attribute to be displayed. The following values are valid: all all characteristics all coun- ters all status global servers local servers The name of a specific attribute from the characteristics, counters, or status group. The attribute specifiers global servers and local servers do not contain any other attributes. DESCRIPTION
The show command displays the names and values of the specified attributes or attribute groups. For attribute groups, if you do not supply a group name with the all argument, all characteristics and their values are displayed. The following sections list names of individual attributes, categorized by group. Note that the attributes displayed by the show command might be different, depending upon whether you have requested information about a server or a clerk. Characteristics Characteristic arguments can contain a maximum of 80 characters and are recalculated to a normalized date format. For example: Input value: 0-0025:10:99.99999999 Result: 1-01:11:39.990 Specifies whether a backup courier is currently functioning as a courier. If the role is noncourier, the node is not attempting to synchro- nize with global servers. This characteristic is shown only for servers. Default: noncourier Value: courier or noncourier Specifies whether automatic changes to the time differential factor are enabled or disabled; the value is determined by the operating sys- tem. Default: true Value: true/false Specifies the amount of time between checks for faulty servers. Applicable only to servers that have external time providers. This charac- teristic is shown only for servers. Default: 0-01:30:00.00 Value: 0-00:00:30.000 - 10675199-02:48:05.478 Specifies the rate at which the DTS server or clerk entity adjusts the node's clock during a synchronization. Specifies the amount of time between system clock ticks. The value is determined by the operating system. Specifies a server's interaction with the set of global servers. This characteristic is shown only for servers. The local server becomes a courier if none are available on the LAN. The local server synchronizes with the global set of servers. The local server does not syn- chronize with the global set of servers. Default: noncourier Specifies the DTS software version installed on the node. Specifies the server's epoch number. The change command modifies this characteristic. This characteristic is shown only for servers. Default: 0 Value: 0-255 Specifies the maximum separation allowed between the local clock and the computed time before synchronizations become abrupt rather than gradual (monotonic). Default: 0-00:10:00.000 Value: 0-00:00:00.500 - 10675199-02:48:05.478 Specifies the amount of time the node waits for a response to a WAN synchronization request before sending another request or declaring a global server to be unavailable. The number of attempts made to reach the server is controlled by the query attemps characteristic. Default: 0-00:00:15.000 Value: 0-00:00:00.000 - 0-00:10:00.000 Specifies the amount of time the node waits for a response to a synchronization request before sending another request or declaring a server to be unavailable. The number of attempts made to reach the server is controlled by the query attemps characteristic. Default: 0-00:00:05.000 Value: 0-00:00:00.000 - 0-00:10:00.000 Specifies the Time Differential Factor (TDF), which is the amount of time the server varies from Greenwich mean time (GMT) or Coordinated Universal Time (UTC). Default: 0-00:00:00.000 Value: -13-00:00:00 - 13-00:00:00 Specifies the worst-case drift rate of the node's clock, in nanoseconds per sec- ond, as determined by the manufacturer's specifications. Specifies the inaccuracy limit for the node. When the node exceeds the maximum inaccuracy setting, it attempts to synchronize. Default: 0-00:00:00.100 Value: 0-00:00:00.0 - 10675199-02:48:05.478 Specifies the future time at which the time differential factor is automatically changed. The value is determined by the operating system. Specifies the number of attempts that a node makes to contact a server before the node considers the server unavailable. Default: 3 Value: 1-10 Specifies a server's ACL entry name; <hostname> represents the name of the system or node that is the server's client. The default setting is the recommended value. This characteristic is shown only for servers. Default: /.:/hosts/<hostname>/dts-entity Specifies the security group name for the time servers within the cell. Default: /.:/subsys/dce/dts-servers Specifies a server's principal name for authentication purposes; <hostname> represents the name of the system or node that is the server's client. The default setting is the recommended value. This characteristic is shown only for servers. Default: /.:/hosts/<hostname>/self Specifies the minimum number of servers required for a synchronization. Settings of 1 or 2 may cause unreliable computed times. Default: 3 Value: 1-10 Specifies the interval a node must wait to synchronize. Also specifies synchronization frequency when a node reaches the value specified by the maximum inaccuracy characteristic. Clerks: Default: 0-00:10:00.0 Value: 0-00:00:30.0 - 01 00:00:00.00 Servers: Default: 0-00:02.00.0 Value: 0-00:00:30.0 - 01 00:00:00.00 Specifies whether or not the entity used an external time provider at the last successful synchronization. This attribute applies to servers only. Specifies the timestamp format used by the node. Specifies whether the node is a DTS server or clerk. The create command modifies this characteristic. Counters Specifies the number of times the node clock has been set nonmonotonically (abruptly). Specifies the time at which the DTS entity was created and the counters were initialized. Specifies the number of times the node received time response messages from servers or clerks that had epoch numbers different from its own. This counter is shown only for servers. Specifies the number of times the DTS has been disabled. Specifies the number of times the DTS has been enabled. Specifies the number of times the server's epoch has changed. Specifies the number of times the node has been unable to allocate virtual memory. Specifies the number of times that a local server was contacted, but it was not in the dts security group. Specifies the number of times the node's time interval failed to intersect with the computed interval of the servers. Specifies the number of times the courier server could not contact any global servers. This counter is shown only for servers. Specifies the number of times the local node failed to process a received message containing an incompatible protocol version. Specifies the number of times that a non-local server was contacted, but it was not in the dts security group. This counter is shown only for servers. Specifies the number of times the courier server could not contact a specific global server. This counter is shown only for servers. Specifies the number of times a server has detected faulty servers (other than itself). This counter is shown only for servers. Specifies the number of times the node successfully synchronized. Specifies the number of times a DTS operation detected a system error. Specifies the number of times the external time provider signaled a failure or the node was unable to access the time provider. Specifies the number of times a dtsd server process initiated contact with a time provider and did not receive the initial response within the interval specified by local set timeout (the default interval is 5 seconds). This counter is shown only for servers. Specifies the number of times the local node failed to process a received message containing an incompatible timestamp format. Specifies the number of times a node failed to synchronize because it could not contact the required minimum number of servers. Specifies the number of times a server has attempted to update its clock. This counter is shown only for servers. Status Specifies the current time on the node. Specifies the set of global servers known by the node. Specifies the computed time at the last attempted synchronization. Specifies the set of local servers known by the node. Specifies the state of the DTS entity. The DTS entity is disabled. The DTS entity is enabled. The DTS entity is synchronizing. The DTS entity is updating the time. Specifies the entity's unique identifier, which is generated when the entity is created. This attribute is shown only for servers. Privilege Required You must have read permission on the ACL associated with the DTS entity in order to execute the command. NOTE
This command is replaced at Revision 1.1 by the dcecp command and may not be provided in future releases of DCE. EXAMPLES
The following command shows how to display the current time: dtscp> show current time Current Time = 1990-11-30-12:11:41.718-05:00I0.359 EST The following command shows how to display all of the entity's characteristic attribute settings: dtscp> show all Check Interval = +0-01:30:00.000I----- Epoch Number = 0 Error Tolerance = +0-00:10:00.000I----- Local Time Differential Factor = -0-04:00:00.000I----- Maximum Inaccuracy = +0-00:00:00.100I----- Servers Required = 3 Query Attempts = 3 Local Set Timeout = +0-00:00:05.000I----- Global Set Timeout = +0-00:00:15.000I----- Synchronization Hold Down = +0-00:02:00.000I----- Type = Server Courier Role = NonCourier Acting Courier Role = NonCourier Clock Adjustment Rate = 40000000 nsec/sec Maximum Clock Drift Rate = 1000000 nsec/sec Clock Resolution = 10000000 nsec DTS Version = V1.0.1 Time Representation Version = V1.0.0 Time Provider Present = FALSE Automatic TDF Change = FALSE Next TDF Change = 1993-10-31-06:00:00.000+00:00I0.000 Server Principal Name = hosts/system1/self Server Entry Name = hosts/system1/dts-entity Server Group Name = sub- sys/dce/dts-servers The following command displays the current values of all characteristic attributes: dtscp> show all characteristics This command produces the same output as does the show all command. Check Interval = +0-01:30:00.000I----- Epoch Number = 0 Error Tolerance = +0-00:10:00.000I----- Local Time Differential Factor = -0-04:00:00.000I----- Maximum Inaccuracy = +0-00:00:00.100I----- Servers Required = 3 Query Attempts = 3 Local Set Timeout = +0-00:00:05.000I----- Global Set Timeout = +0-00:00:15.000I----- Synchronization Hold Down = +0-00:02:00.000I----- Type = Server Courier Role = NonCourier Acting Courier Role = NonCourier Clock Adjustment Rate = 40000000 nsec/sec Maximum Clock Drift Rate = 1000000 nsec/sec Clock Resolution = 10000000 nsec DTS Version = V1.0.1 Time Representation Version = V1.0.0 Time Provider Present = FALSE Automatic TDF Change = FALSE Next TDF Change = 1993-10-31-06:00:00.000+00:00I0.000 Server Principal Name = hosts/system1/self Server Entry Name = hosts/system1/dts-entity Server Group Name = sub- sys/dce/dts-servers The following command shows how to display all of the local servers known to the entity: dtscp> show local servers Known Servers ============================================================ Local /.../sisyphus.osf.org/hosts/system2/self Last Time Polled = 1993-10-15-21:01:46.124+00:00I0.809 Last Observed Time = 1993-10-15-21:03:09.041+00:00I----- Last Observed Skew = +0-00:01:22.917I----- Used in Last Synchronization = TRUE Transport Type = RPC Local /.../sisyphus.osf.org/hosts/system3/self Last Time Polled = 1993-10-15-21:01:46.124+00:00I0.809 Last Observed Time = 1993-10-15-21:01:46.143+00:00I0.817 Last Observed Skew = +0-00:00:00.019I1.625 Used in Last Synchronization = TRUE Transport Type = RPC The following command displays the current values of all counter attributes: dtscp> show all counters Creation Time = 1993-10-14-16:23:57.801+00:00I0.767 Local Times Not Intersecting = 0 Server Times Not Intersecting = 0 Different Epochs Detected = 0 Too Few Servers Detected = 0 Time Provider Timeouts Detected = 1 Protocol Mismatches Detected = 0 Time Representation Mismatches Detected = 0 No Global Servers Detected = 0 Servers Not Responding = 0 Clock Settings = 0 Epoch Changes Completed = 0 System Errors Detected = 0 Synchronizations Completed = 865 Updates Initiated = 0 Enable Directives Completed = 1 Disable Directives Completed = 0 Insufficient Resources Detected = 0 Time Provider Failures Detected = 0 Local server not in group = 0 Servers not in group = 0 The following command displays the current values of all status attributes: dtscp> show all status UID = 00004e34-5e1c-2c87-8500-08005a0d4582 Last Synchronization = 1993-10-15-21:05:43.023+00:00I----- State = On The following command displays the current value of the courier role attribute: dtscp> show courier role Courier Role = NonCourier The following command displays the server entry name for this server: dtscp> show server entry name Server Entry Name = hosts/system1/dts-entity The following command displays the current state of the Time Service entity: dtscp> show state State = On The following command displays the current value of the check interval attribute: dtscp> show check interval Check Interval = +0-01:30:00.000I----- The following command displays the current value of the servers times not intersecting counter: dtscp> show servers times not intersecting Server Times Not Intersecting = 0 RELATED INFORMATION
Commands: set(1m) show(1m)
All times are GMT -4. The time now is 06:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy