Multiple File creation from Single file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple File creation from Single file
# 8  
Old 04-08-2014
Quote:
Originally Posted by Franklin52
In this case you could try:
Code:
awk '/^RC No/{close(f);f=$NF}{print >> f}' test.txt

Hello Fraklin52,
Still getting same error Smilie
Code:
awk '/^RC No/{close(f);f=$NF}{print >> f}' test.txt
awk: (FILENAME=test.txt FNR=1) fatal: expression for `>>' redirection has null string value


Last edited by Scott; 04-08-2014 at 11:05 AM.. Reason: Code tags
# 9  
Old 04-08-2014
Then, has the very first line in your input file that "RC No" pattern in it?
# 10  
Old 04-08-2014
Quote:
Originally Posted by RudiC
Then, has the very first line in your input file that "RC No" pattern in it?
Hello Rudic,
Yes, file has "RC No" in very first line of the file.
# 11  
Old 04-08-2014
Quote:
Originally Posted by Steven77
Hello Fraklin52,
Still getting same error Smilie


awk '/^RC No/{close(f);f=$NF}{print >> f}' test.txt
awk: (FILENAME=test.txt FNR=1) fatal: expression for `>>' redirection has null string value
Please provide a realistic example of your input file.
# 12  
Old 04-08-2014
Below are the realistic contect of my original file:

Code:
  RC No./Name :       0001     /Kosba office branch                        Dhapa Advertised Match PCL.
  Report Name  : SEZ223 DAILY EXPENSE ALLOCATE TO OTHER                                                  Page     : 1 of 8
  As of        : 31-JAN-14                                                                                 Run Date : 04 APR 2014
                                                                                                           Run Time : 18:41:11
  RC No./Name :       0001     /Kosba office branch
  Report Name  : SEZ223 DAILY EXPENSE ALLOCATE TO OTHER                                                  Page     : 6 of 8
  As of        : 31-JAN-14                                                                                 Run Date : 04 APR 2014

  RC No./Name :       0001     /Kosba office branch
  Report Name  : SEZ223 DAILY EXPENSE ALLOCATE TO OTHER                                                  Page     : 8 of 8
  As of        : 31-JAN-14                                                                                 Run Date : 04 APR 2014
                                                                                                           Run Time : 18:41:11
  RC No./Name :       0002     /Rathtala branch                              Dhapa Advertised Match PCL.
  Report Name  : SEZ223 DAILY EXPENSE ALLOCATE TO OTHER                                                  Page     : 1 of 2
  As of        : 31-JAN-14                                                                                 Run Date : 04 APR 2014
                                                                                                           Run Time : 18:41:11
  RC No./Name :       0002     /Rathtala branch
  Report Name  : SEZ223 DAILY EXPENSE ALLOCATE TO OTHER                                                  Page     : 2 of 2
  As of        : 31-JAN-14                                                                                 Run Date : 04 APR 2014
                                                                                                           Run Time : 18:41:11
   Total RC :                                                        0.00                 120.00

  RC No./Name :       0003     /Bang lampu branch                            Dhapa Advertised Match PCL.
  Report Name  : SEZ223 DAILY EXPENSE ALLOCATE TO OTHER                                                  Page     : 1 of 2
  As of        : 31-JAN-14                                                                                 Run Date : 04 APR 2014
   Total RC :                                                        0.00                  60.00
   : 31-JAN-14


Last edited by Franklin52; 04-08-2014 at 03:56 PM.. Reason: Please use code tags
# 13  
Old 04-08-2014
Code:
awk '/Total RC/{next}/RC No/{close(f);f=$4}{print >> f}' test.txt


Last edited by Franklin52; 04-08-2014 at 04:44 PM..
# 14  
Old 04-09-2014
Quote:
Originally Posted by Franklin52
Code:
awk '/Total RC/{next}/RC No/{close(f);f=$4}{print >> f}' test.txt

Hello Franklin52,
Thanks for your help. Now with new command last line i.e "Total RC" is not coming in any files.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Output file name and file contents of multiple files to a single file

I am trying to consolidate multiple information files (<hostname>.Linux.nfslist) into one file so that I can import it into Excel. I can get the file contents with cat *Linux.nfslist >> nfslist.txt. I need each line prefaced with the hostname. I am unsure how to do this. --- Post updated at... (5 Replies)
Discussion started by: Kentlee65
5 Replies

2. Shell Programming and Scripting

Script to access multiple file and operate on single file

We have three files as mentioned below: 1. main_file.txt: This is the file in which all operations will be done. Which means this file will be signed by using the below two files 2. signature_file.txt: This is a status file and contains two signatures. 3. command.txt:file contains two commands... (2 Replies)
Discussion started by: chetanojha
2 Replies

3. Shell Programming and Scripting

Multiple file and single parameter file

Hi Team, In our project we have written below 2 scripts like Script1: Shell script start & END Begin Audit process - uses teradata bteq END Audit Process Script 2: Environemtal variable file different Now Client ask to change this requirement and need below files: Script1:... (1 Reply)
Discussion started by: tusharzaware1
1 Replies

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

5. Shell Programming and Scripting

Shell scripting - need to arrange the columns from multiple file into a single file

Hi friends please help me on below, i have 5 files like below file1 is x 10 y 20 z 15 file2 is x 100 z 245 file3 is y 78 z 23 file4 is x 100 (3 Replies)
Discussion started by: siva kumar
3 Replies

6. Shell Programming and Scripting

How to make multiple small file out of a single file?

Hi, I have a file that consist of around six million line, now the task is to divide this file into 12 small file so that each file would have half a million lines in it. Thanks. (3 Replies)
Discussion started by: mukulverma2408
3 Replies

7. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

8. UNIX for Dummies Questions & Answers

how to append into single file for multiple iterations

hi, i want to capture the CPU performance, memory , harddisk usage into a single file for every 10 seconds iterations and it shall run until i kill it. can somebody plz help me in this... thanx (1 Reply)
Discussion started by: bskumar4u
1 Replies

9. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

10. Shell Programming and Scripting

Single to multiple line file

I am working with single line file with 589744523 characters having 542 "^M" (line feed) character. I want to make 542 different lines file from the single line file thr. shell program only (it can be done thr vi command) rd anil sorry for duplicate post previously, actually i don,t know... (6 Replies)
Discussion started by: anil_kut
6 Replies
Login or Register to Ask a Question