Sponsored Content
Full Discussion: Splitting the file
Top Forums Shell Programming and Scripting Splitting the file Post 302658561 by atlantis_yy on Tuesday 19th of June 2012 12:40:06 PM
Old 06-19-2012
Splitting the file

I have a format of file, I need to seperate the file the different colored data to separate files like file1, file2 and file 3. Also replace '*' with '|' and if there is any '~' replace with '\n' with the help of unix script

Code:
ISA*00**00**02*CN*ZZ*RECEIVER ID*060628*0035*U*00201*000000612*0*P*> 
GS*IM*CN*APPLICATION RECEIVER ID*20060628*0035*612*X*004010 
ST*210*612001 
B3*B*28061234*102141*PP**20060628*208360****CNRU 
N1*PR*PAYER NAME*25*772305B 
N3*123 NEWBRIDGE ROAD . 
N4*ETOBICOKE*ON 
N1*CN*CONSIGNEE NAME*25*772305 
N3*1800 INKSTER BLVD 
N4*WINNIPEG SYMING YAR*MB*R2X2Z5 
N1*SF*SHIP FROM NAME*25*772305 
N3*123 NEWBRIDGE RD 
N4*ETOBICOKE*ON 
SE*33*612001 
ST*210*612001 
B3*B*28061234*102141*PP**20060628*208360****CNRU 
N1*PR*PAYER NAME*25*772305B 
N3*123 NEWBRIDGE ROAD . 
N4*ETOBICOKE*ON 
N3*123 NEWBRIDGE ROAD . 
N4*ETOBICOKE*ON 
N3*123 NEWBRIDGE ROAD . 
N4*ETOBICOKE*ON 
N1*CN*CONSIGNEE NAME*25*772305 
N3*1800 INKSTER BLVD 
N4*WINNIPEG SYMING YAR*MB*R2X2Z5 
N1*SF*SHIP FROM NAME*25*772305 
N3*123 NEWBRIDGE RD 
N4*ETOBICOKE*ON 
SE*33*612001 
ST*210*612001 
B3*B*28061234*102141*PP**20060628*208360****CNRU 
N1*PR*PAYER NAME*25*772305B 
N3*123 NEWBRIDGE ROAD . 
N4*ETOBICOKE*ON 
N1*CN*CONSIGNEE NAME*25*772305 
N3*1800 INKSTER BLVD 
N4*WINNIPEG SYMING YAR*MB*R2X2Z5 
N1*SF*SHIP FROM NAME*25*772305 
N3*1800 INKSTER BLVD 
N4*WINNIPEG SYMING YAR*MB*R2X2Z5 
N1*SF*SHIP FROM NAME*25*772305 
N3*123 NEWBRIDGE RD 
N4*ETOBICOKE*ON 
SE*33*612001 
GE*1*612 
IEA*1*000000612

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Splitting file] Extracting group of segments from one file to others

Hi there, I need to split one huge file into separate files if the condition is fulfilled according to that the position between 97 and 98 matches with “IT” at the segment MAS. There is no delimiter file is fix-width with varous line length. Could you please help me how I do split the file... (1 Reply)
Discussion started by: ozgurgul
1 Replies

2. UNIX for Dummies Questions & Answers

Splitting a file based on record sin another file

All, We receive a file with a large no of records (records can vary) and we have to split it into two files based on another file. e.g. File1: UHDR 2008112 "25187","00000022","00",21-APR-1991,"" ,"D",-000000519,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,21-APR-1991... (7 Replies)
Discussion started by: er_ashu
7 Replies

3. Shell Programming and Scripting

splitting the file

Hi , I have one file which has many headers. Say suppose HEDAER ..data DATA DATA ..data ..data HEADER ..data ..data DATA .data HEADER. ..data ..data If there are 3 HEADERS in source file then I need to split the source file into 3 separate file.... (2 Replies)
Discussion started by: tanyaheerani
2 Replies

4. Shell Programming and Scripting

File splitting, naming file according to internal field

Hi All, I have a rather stange set of requirements that I'm hoping someone here could help me with. We receive a file that is actually a concatenation of 4 files (don't believe this would change, but ideally the solution would handle n files). The super-file looks like:... (7 Replies)
Discussion started by: Leedor
7 Replies

5. Shell Programming and Scripting

Splitting a file in to multiple files and passing each individual file to a command

I have an input file with contents like: MainFile.dat: 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 ... (4 Replies)
Discussion started by: rkrish
4 Replies

6. UNIX for Dummies Questions & Answers

Extracting data from one file, based on another file (splitting)

Dear All, I have two files but want to extract data from one based on another... can you please help me file 1 David Tom Ellen and file 2 David|0010|testnamez|resultsz David|0004|testnamex|resultsx Tom|0010|testnamez|resultsz Tom|0004|testnamex|resultsx Ellen|0010|testnamez|resultsz... (12 Replies)
Discussion started by: A-V
12 Replies

7. Shell Programming and Scripting

Splitting XML file on basis of line number into multiple file

Hi All, I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom. from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Discussion started by: ajju
14 Replies

8. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header”H” trl=$(cut -c|path$file|tail -1)#extract trailer “T” SplitFile=$(cut -c 50-250 $path 1$newfile |sed'$/ *$//' head -1')# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do... (4 Replies)
Discussion started by: SwagatikaP1
4 Replies

9. Shell Programming and Scripting

Splitting a text file into smaller files with awk, how to create a different name for each new file

Hello, I have some large text files that look like, putrescine Mrv1583 01041713302D 6 5 0 0 0 0 999 V2000 2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

10. UNIX for Beginners Questions & Answers

Splitting the file based on two fields - Fixed length file

Hi , I am having a scenario where I need to split the file based on two field values. The file is a fixed length file. ex: AA0998703000000000000190510095350019500010005101980301 K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies
Perl::Critic::Policy::ControlStructures::ProhibitUnreachUserCContributed Perl DPerl::Critic::Policy::ControlStructures::ProhibitUnreachableCode(3)

NAME
Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode - Don't write code after an unconditional "die, exit, or next". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
This policy prohibits code following a statement which unconditionally alters the program flow. This includes calls to "exit", "die", "return", "next", "last" and "goto". Due to common usage, "croak" and "confess" from Carp are also included. Code is reachable if any of the following conditions are true: o Flow-altering statement has a conditional attached to it o Statement is on the right side of an operator "&&", "||", "//", "and", "or", or "err". o Code is prefixed with a label (can potentially be reached via "goto") o Code is a subroutine EXAMPLES
# not ok exit; print "123 "; # ok exit if !$xyz; print "123 "; # not ok for ( 1 .. 10 ) { next; print 1; } # ok for ( 1 .. 10 ) { next if $_ == 5; print 1; } # not ok sub foo { my $bar = shift; return; print 1; } # ok sub foo { my $bar = shift; return if $bar->baz(); print 1; } # not ok die; print "123 "; # ok die; LABEL: print "123 "; # not ok croak; do_something(); # ok croak; sub do_something {} CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls AUTHOR
Peter Guzis <pguzis@cpan.org> COPYRIGHT
Copyright (c) 2006-2011 Peter Guzis. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.16.3 2014-06-09 Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode(3)
All times are GMT -4. The time now is 11:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy