Visit Our UNIX and Linux User Community


Append each line based upon the character size

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Append each line based upon the character size
# 1  
Old 04-05-2017
Blade Append each line based upon the character size

I have a huge file which contains multiple lines. It need to check whether character length is not more than 255 each line. If its not then it should remove the
character up to column. I have described in the output below. If its more than that
the next line should start with call but if the table name varies then it should not merge to the same line. The output should go to the 4 different file based upon the table name in the 3rd column below. 5th table in the list should again go the first file.

Input:
Code:
call mq_dbrebuildindex('SCS.services_HIST','column [end_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [status]');
call mq_dbrebuildindex('SCS.services_HIST','column [survey]');
call mq_dbrebuildindex('SCS.services_HIST','column [file_id]');
call mq_dbrebuildindex('SCS.services_HIST','column [opt_out]');
call mq_dbrebuildindex('SCS.services_HIST','column [start_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [dw_load_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [pip_brands]');
call mq_dbrebuildindex('SCS.services_HIST','column [finalize_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [scs_service]');
call mq_dbrebuildindex('SCS.services_HIST','column [pharmacy_ncpdp]');
call mq_dbrebuildindex('SCS.services_HIST','column [contract_term_sheet]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [file_id]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [fnlndbs]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [payer_id]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [pip_edit]');


Output:
File:1
Code:
call mq_dbrebuildindex('SCS.services_HIST','column [end_dt]) column [status] column [survey] column [file_id]) column [opt_out] column [start_dt] column [dw_load_dt] column [pip_brands] column [finalize_dt] column [scs_service] column [pharmacy_ncpdp]');
call mq_dbrebuildindex('SCS.services_HIST','column [contract_term_sheet]');

File:2
Code:
call mq_dbrebuildindex('SCS.reporting_opportunities','column [file_id] column [fnlndbs]column [payer_id]column [pip_edit]column [client_id]column [person_id]column [rx_number]column [copay_tier]column [dw_load_dt]column [patient_id]column [program_id]')
call mq_dbrebuildindex('SCS.reporting_opportunities','column [billing_ndc]column [days_supply]column [employer_id]column [fill_number]column [claim_number]column [client_id_cd]column [pharmacy_npi]column [processed_dt]column [date_of_birth]')
call mq_dbrebuildindex('SCS.reporting_opportunities','column [employer_name]column [latest_fax_id]column [prescriber_id]column [record_source]column [patient_gender]column [pharmacy_ncpdp]column [transaction_cd]column [date_of_service]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [date_rx_written]column [earliest_fax_id]column [patient_pay_amt]column [transaction_type]column [dispense_event_id]column [dispensing_status]column [patient_gender_cd]');

File:3

File:4

Last edited by Don Cragun; 04-05-2017 at 09:51 PM.. Reason: Add CODE and ICODE tags again.
# 2  
Old 04-05-2017
Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework forum under special homework rules.

If you did not post homework, please:
  1. explain the company you work for and the nature of the problem you are working on,
  2. tell us what operating system you're using,
  3. tell us what shell you're using,
  4. show us what code you have written to try to solve this problem on your own,
  5. explain how four columns specified in your sample input for table SCS.reporting_opportunities is supposed to magically be turned into over thirty columns of sample output, and
  6. explain how your code is supposed to determine which format of output is supposed to be produced based on the name of the table being processed. (Note that in your sample output, columns for table SCS.services_HIST have a <space> in the output before each column string; but in the output for table SCS.reporting_opportunities, there is no <space> before column after the closing square brackets.)

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Previous Thread | Next Thread
Test Your Knowledge in Computers #61
Difficulty: Easy
A computer on a LAN segment is uniquely identified by its MAC address.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cut each line based on the character size

Hello All, I have a file which contain below lines. The starting word of each line is call and the end line is semi colon. I need to find the character size of each line and then move it to a file. If the character size is more than 255 then I need to push that line to a next file and I need... (6 Replies)
Discussion started by: JoshvaPeter
6 Replies

2. Shell Programming and Scripting

To append new data at the end of each line based on substring of last column

Hi guys, I need to append new data at the end of each line of the files. This new data is based on substring (3rd fields) of last column. Input file xxx.csv: U1234|1-5X|orange|1-5X|Act|1-5X|0.1 /sac/orange 12345 0 U5678|1-7X|grape|1-7X|Act|1-7X|0.1 /sac/grape 5678 0... (5 Replies)
Discussion started by: null7
5 Replies

3. Shell Programming and Scripting

Search for a string, then append character to end of that line only

I have 2 files that I am working with $ cat file1 server1 server3 server5 server6 server8 $ cat file2 server1;Solaris; server2; SLES; server3;Linux; server4; Solaris; server5;SLES; server6;SLES; server7;Solaris; server8;Linux; (1 Reply)
Discussion started by: snoman1
1 Replies

4. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

5. Shell Programming and Scripting

Match data based on two fields, and append to a line

I need to write a program to do something like a 'vlookup' in excel. I want to match data from file2 based on two fields (where both match) in file1, and for matching lines, add the data from two of the fields from file2 to file1. If anyone knows something in perl or awk that can do this, I'd be... (20 Replies)
Discussion started by: jamessmith01
20 Replies

6. Shell Programming and Scripting

How to append a character to the last but one field on a specific line?

Hi Guys, I have a file like this: aaa b c d e f fsss g h i k l qqq r t h n I want: aaa b c d e f fsss g h i k l qqq r t h , n ggg p t e d u qqq i o s , k (2 Replies)
Discussion started by: npatwardhan
2 Replies

7. Shell Programming and Scripting

append a character at end of each line of a file

Hi, i want to append a character '|' at end of each line of a file abc.txt. for example if the file abc.txt conatins: a|b|c 1|2|33 w|2|11 i want result file xyz.txt a|b|c| 1|2|33| w|2|11| I know this is simple but sumhow i am not able to reach end of line. its urgent, thanks for... (4 Replies)
Discussion started by: muaz
4 Replies

8. Shell Programming and Scripting

Append line based on fixed position

Hi all; I'm having headache on append one line to another based on the fix position.Hope u guys can help. All i need to do is append the line that start with '3' to a line which start with '1' and the position for line 3 that i need to append is 22. The original file look like this: ... (2 Replies)
Discussion started by: ashikin_8119
2 Replies

9. Shell Programming and Scripting

Using SED to append character to each line

Hey - my first post here, and I'm a total SED newb. I've looked around for previous help on this, but have so far been unsuccessful. I have a program (AMStracker for OS X) that outputs data in the terminal. Output is in this form: . . . 3 0 -75 3 0 -76 3 0 -77 ... (4 Replies)
Discussion started by: c0nn0r
4 Replies

10. UNIX for Dummies Questions & Answers

delete a line based on first character of the line

Hi, I need to delete all lines in a file which starts with "|" character. Can some one assist me? Thanks (2 Replies)
Discussion started by: borncrazy
2 Replies

Featured Tech Videos