Split File based on different conditions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Split File based on different conditions
# 1  
Old 05-21-2014
Split File based on different conditions

I need to split the file


Conditions:

  • Ignore any record that either starts with 1 or 9

  • Split the file at position 404 , if position 404 is abc or def then write all the records in a file > File 1 , the remaining records should go in to a file > File 2

  • Further I want to split the File 1 by number of records , each file should have ~ 5+ records, while we are splitting the File 1 by number of records we need to make sure that the first record in the each individual split files should always start with 2

  • All the individual splits of File 1 should have a unique name e.g. test001.txt , test002.txt e.t.c
Input File :
Code:
100000035900015300007538 xxxxxxxxxxxxxx                      xxxxxxxxxxxx                  xxxxxxxxxxxxxxxxxxxxx         20140206xxxxxxx ONLY2014020720140207                                                                                                                                                                                                                                                                                                                                                                                          ,
200000035900015300007538 xxxxxT00106006900000000000DD000000000N000000000N00NxxxxxxxxD      N Nxxxxxxxxxxx                   N0954106        N19830312N20100609NMN          N             00000000N                 xxxx xxxxxxxxxxxxx, xxxx      N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300007538 xxxxxT00106006901047119889D 000000000N000000000N01NxxxI           N Nxxxxxxxxxxxxx                 N               N19830411N00000000NFN          N             00000000N                 xxxx xxxxxxxxxxxxx, xxxx      N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300007538 xxxxxx00106006902000000000D 000000000N000000000N03NxxxxV          N xxxxxxxxxx                     N               N20130204N00000000NMN          N             00000000N                 xxxx xxxxxxxxxxxxx, xxxx      N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,        
200000035900015300007538 xxxxxx00106795800000000000DD000000000N000000000N00NxxxL           NQxxxxxxx                        N1106919        N19750730N20130116NMN          N             00000000N                 5xx xxxxxxxxxxxxx             N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300007538 xxxxxx00106795801001025245D 000000000N000000000N01Nxxxxxxx        N xxxxxxx                        N               N19810520N00000000NFN          N             00000000N                 xxx xxxxxxxxxxxxx             N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300007538 xxxxxx00106795802002089044D 000000000N000000000N03Nxxxxxxx        NAxxxxxxx                        N               N20091011N00000000NMN          N             00000000N                 xxxxxxxxxxxxxxxxx             N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
200000035900015300007538 xxxxxx00108663200000000000DD000000000N000000000N00Nxxxxx          NAxxxxxxx                        N0932180        N19780804N20091222NMN          N             00000000N                 xxxxx xxxxxxxxxxx             N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
300000035900015300007538 xxxxxxx0108663201489622096D 000000000N000000000N01Nxxxxxx         N xxxxxxx                        N               N19540403N00000000NFN          N             00000000N                 1xxxxxxxxxxxxxxxx             N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
200000035900015300007538 xxxxxx00138593700000000000DD000000000N000000000N00Nxxxx           N NMxxxx                         N0880971        N19620604N19910528NMN          N             00000000N                 Pxxxxxxxxxxxxx                N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNdef            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
200000035900015300007538 xxxxxx00140226500000000000DD000000000N000000000N00Nxxxx           NFNxxxxxxxxx                     N0918118        N19500906N20090930NMN          N             00000000N                 xxxxxxxxxxxxxxxxxxxxxxxx      N                              N                              NxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNCVS            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
900000035900015300007538 xxxxxxxxxxxxxx                      xxxxxxxxxxxx                  xxxxxxxxxxxxxxxxxxxxx         2014020600729850074150                                                                                                                                                                                                                                                                                                                                                                                                        ,
100000035900015300107538 xxxxxxxxxxxxxx                      xxxxxxxxxxxx                  xxxxxxxxxxxxxxxxxxxxx         20140206CHANGES ONLY2014020720140207                                                                                                                                                                                                                                                                                                                                                                                          ,
200000035900015300107538 xxxxxxxxxxxxxxxxxxxxxxxxxx                                                                                                                                                                                                                                                             xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300107538 xxxxxx00106006901047119889A 000000000Y000000000Y01xxxxx           Y Yxxxxxxxxxxxxx                 Y               Y19830411Y00000000YFY          Y             00000000Y                 xxxxxxxxxxxxxxxxxxxxxxxx      Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,        
300000035900015300107538 xxxxxx00106006902000000000A 000000000Y000000000Y03YxxxxV          Y Yxxxxxxxxx                     Y               Y20130204Y00000000YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxxxxxxxx5      Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
200000035900015300107538 xxxxxx00106795800000000000AA000000000Y000000000Y00Yxxxx           YQxxxxxxx                        Y1106919        Y19750730Y20130116YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300107538 xxxxxx00106795801001025245A 000000000Y000000000Y01Yxxxxxxx        Y xxxxxxx                        Y               Y19810520Y00000000YFY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300107538 xxxxxx00106795802002089044A 000000000Y000000000Y03Yxxxxxxx        YAxxxxxxx                        Y               Y20091011Y00000000YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
200000035900015300107538 xxxxxx00108663200000000000AA000000000Y000000000Y00Yxxxxx          YAxxxxxxx                        Y0932180        Y19780804Y20091222YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
300000035900015300107538 xxxxxx00108663201489622096A 000000000Y000000000Y01Yxxxxxx         Y xxxxxxx                        Y               Y19540403Y00000000YFY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
200000035900015300107538 xxxxxx00138593700000000000AA000000000Y000000000Y00Yxxxx           Y Yxxxxx                         Y0880971        Y19620604Y19910528YMY          Y             00000000Y                 xxxxxxxxxxxxxx                Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYdef            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
900000035900015300107538 xxxxxxxxxxxxxx                      xxxxxxxxxxxx                  xxxxxxxxxxxxxxxxxxxxx         2014020600765120075547                                                                                                                                                                                                                                                                                                                                                                                                        ,
100000035900015300107538 xxxxxxxxxxxxxx                      xxxxxxxxxxxx                  xxxxxxxxxxxxxxxxxxxxx         20140206CHANGES ONLY2014020720140207                                                                                                                                                                                                                                                                                                                                                                                          ,
200000035900015300107538 xxxxxxxxxxxxxxxxxxxxxxxxxx                                                                                                                                                                                                                                                             xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYMVE            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300107538 xxxxxx00106006901047119889A 000000000Y000000000Y01xxxxx           Y Yxxxxxxxxxxxxx                 Y               Y19830411Y00000000YFY          Y             00000000Y                 xxxxxxxxxxxxxxxxxxxxxxxx      Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYMVE            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,        
300000035900015300107538 xxxxxx00106006902000000000A 000000000Y000000000Y03YxxxxV          Y Yxxxxxxxxx                     Y               Y20130204Y00000000YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxxxxxxxx5      Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYXYZ            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
200000035900015300107538 xxxxxx00106795800000000000AA000000000Y000000000Y00Yxxxx           YQxxxxxxx                        Y1106919        Y19750730Y20130116YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYMVE            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300107538 xxxxxx00106795801001025245A 000000000Y000000000Y01Yxxxxxxx        Y xxxxxxx                        Y               Y19810520Y00000000YFY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYMVE            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
300000035900015300107538 xxxxxx00106795802002089044A 000000000Y000000000Y03Yxxxxxxx        YAxxxxxxx                        Y               Y20091011Y00000000YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,
200000035900015300107538 xxxxxx00108663200000000000AA000000000Y000000000Y00Yxxxxx          YAxxxxxxx                        Y0932180        Y19780804Y20091222YMY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYdef            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
300000035900015300107538 xxxxxx00108663201489622096A 000000000Y000000000Y01Yxxxxxx         Y xxxxxxx                        Y               Y19540403Y00000000YFY          Y             00000000Y                 xxxxxxxxxxxxxxxxx             Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYabc            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
200000035900015300107538 xxxxxx00138593700000000000AA000000000Y000000000Y00Yxxxx           Y Yxxxxx                         Y0880971        Y19620604Y19910528YMY          Y             00000000Y                 xxxxxxxxxxxxxx                Y                              Y                              YxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYdef            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
900000035900015300107538 xxxxxxxxxxxxxx                      xxxxxxxxxxxx                  xxxxxxxxxxxxxxxxxxxxx         2014020600765120075547                                                                                                                                                                                                                                                                                                                                                                                                        ,

Thank you

Last edited by Scott; 05-21-2014 at 04:00 PM.. Reason: Use code tags, please...
# 2  
Old 05-21-2014
Hello.

What have you tried? Where are you stuck?
This User Gave Thanks to Scott For This Post:
# 3  
Old 05-22-2014
Sorry for not using code tags , moving forward I will make sure that I use them

I havent had any luck with it , any help is greatly appreciated


Thanks in advance

---------- Post updated at 11:39 PM ---------- Previous update was at 03:57 PM ----------

Hello,

Can anyone please provide me some help and direction ?

Thanks in advance
# 4  
Old 05-22-2014
Same question again
What have u tried?
# 5  
Old 05-23-2014
Here is what I have so far !

I have marked the areas where I need help

Code:
#!/usr/bin/ksh

# Get all the records except for the ones that start with 1 or 9

grep "^[^1|9]" Input.txt > Output.txt

# Get all the records that have abc at position 404

cat Output.txt |awk 'substr($0,404,3)=="abc" {print}' > File1.txt

# Get all the records that have def at position 404

cat Output.txt |awk 'substr($0,404,3)=="def" {print}' >> File1.txt

# Get all the records that have do NOT have abc or def  at position 404 -- Need Help !

# Get all the records that have spaces at position 404  -- Need Help !

# Split the File1.txt -- Need Help !

   # ~ 5 Records in each individual split files with uniqe name on each file
   
   # while we are splitting the File 1 by number of records we need to make sure that the first record in the each individual split files should always start with 2 
   
   # Include the header ( first record of the input file) and trailer record( last record in the input file)in each individual file

Any help is greatly appreciated !

Thank you
# 6  
Old 05-23-2014
Here's something to start with for items 1 and 2:
Code:
awk '/^[19]/{next} {ss=substr($0,404,3); out=(ss=="abc" || ss=="def")? "file1":"file2"; print >out}' myFile

# 7  
Old 05-23-2014
Thanks vgersh99!

Can you please explain the code

Appreciate it!

---------- Post updated at 02:22 PM ---------- Previous update was at 11:21 AM ----------

Scripting gurus need help on this !

Split the File1.txt

# ~ 5 Records in each individual split files with uniqe name on each file

# while we are splitting the File 1 by number of records we need to make sure that the first record in the each individual split files should always start with 2

# Include the header ( first record of the input file) and trailer record( last record in the input file)in each individual file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and replace value based on certain conditions in a fixed width file

Hi Forum. I tried searching for a solution using the internet search but I haven't been able to find any solution for what I'm trying to accomplish. I have a fixed width column file where I need to search for any occurrences of "D0" in col pos.#1-2, 10-11, 20-21 and replaced it with "XD". ... (2 Replies)
Discussion started by: pchang
2 Replies

2. Shell Programming and Scripting

awk to update file based on 5 conditions

I am trying to use awk to update the below tab-delimited file based on 5 different rules/conditions. The final output is also tab-delimited and each line in the file will meet one of the conditions. My attemp is below as well though I am not very confident in it. Thank you :). Condition 1: The... (10 Replies)
Discussion started by: cmccabe
10 Replies

3. Shell Programming and Scripting

awk to filter file based on seperate conditions

The below awk will filter a list of 30,000 lines in the tab-delimited file. What I am having trouble with is adding a condition to SVTYPE=CNV that will only print that line if CI= must be >.05 . The other condition to add is if SVTYPE=Fusion, then in order to print that line READ_COUNT must... (3 Replies)
Discussion started by: cmccabe
3 Replies

4. Shell Programming and Scripting

Help with Creating file based on conditions

Can anyone please assist? I have a .txt file(File1.txt) and a property file(propertyfile.txt) . I have to read the vales from the property file and .txt file and create the output file(outputfile.txt) mentioned in the attachment. For each record in .txt file,the below mentioned values shall be... (20 Replies)
Discussion started by: vinus
20 Replies

5. Shell Programming and Scripting

Create new file with increment column based on conditions

Hello, Using bash script, i need to process the following file: 887,86,,2013-11-06,1,10030,5,2,0,200,, 887,86,,2013-11-05,1,10030,5,2,0,199,, 887,138,,2013-11-06,1,10031,6,2,0,1610612736,, 887,164,,2013-11-06,1,10000,0,2,0,36000,, and to create a new file such as the below ... (2 Replies)
Discussion started by: JonhyDeep
2 Replies

6. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

7. UNIX for Dummies Questions & Answers

Split file based on column

i have file1.txt asdas|csada|130310|0423|A1|canberra sdasd|sfdsf|130426|2328|A1|sydney Expected output : on eaceh third and fourth colum, split into each two characters asdas|csada|13|03|10|04|23|A1|canberra sdasd|sfdsf|13|04|26|23|28|A1|sydney (10 Replies)
Discussion started by: radius
10 Replies

8. Shell Programming and Scripting

Extract file records based on some field conditions

Hello Friends, I have a file(InputFile.csv) with the following columns(the columns are pipe-delimited): ColA|ColB|ColC|ColD|ColE|ColF Now for this file, I have to get those records which fulfil the following condition: If "ColB" is NOT NULL and "ColD" has values one of the following... (9 Replies)
Discussion started by: mehimadri
9 Replies

9. UNIX for Dummies Questions & Answers

How to get remove duplicate of a file based on many conditions

Hii Friends.. I have a huge set of data stored in a file.Which is as shown below a.dat: RAO 1869 12 19 0 0 0.00 17.9000 82.3000 10.0 0 0.00 0 3.70 0.00 0.00 0 0.00 3.70 4 NULL LEE 1870 4 11 1 0 0.00 30.0000 99.0000 0.0 0 0.00 0 0.00 0.00 0.00 0 ... (3 Replies)
Discussion started by: reva
3 Replies

10. Shell Programming and Scripting

validating a file based on conditions

i have a file in unix in which the records are like this aaa 123 233 aaa 234 222 aaa 242 222 bbb 122 111 bbb 122 123 ccc 124 222 In the output i want only the below records aaa ccc The validation logic is 1st column and 2nd column need to be considered if both columns values are... (8 Replies)
Discussion started by: trichyselva
8 Replies
Login or Register to Ask a Question