Adding Extra Column in txt file base on Condition

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
# 1  
Adding Extra Column in txt file base on Condition

HI Guys,

I have below input.

Output Base on Below Condition.

1> if forth column is empty and next coming line have same name with \es then add that column name on all rows
2>rest of all are es:vsDataEUtranCellFDD
CCL01736	CCL01736_7A_1	es:vsDataEUtranCellFDD		
CCL01736	CCL01736_7A_1	es:frameStartOffset		
CCL01736	CCL01736_7A_1	es:subFrameOffset	0	
CCL01736	CCL01736_7A_1	es:timeOffset	0	
CCL01736	CCL01736_7A_1	/es:frameStartOffset		
CCL01736	CCL01736_7A_1	es:systemInformationBlock6		
CCL01736	CCL01736_7A_1	es:tReselectionUtra	2	
CCL01736	CCL01736_7A_1	es:tReselectionUtraSfMedium	100	
CCL01736	CCL01736_7A_1	es:tReselectionUtraSfHigh	100	
CCL01736	CCL01736_7A_1	/es:systemInformationBlock6		
CCL01736	CCL01736_7A_1	es:timeOffset	0	
CCL01736	CCL01736_7A_1	es:vsDataEUtranCellFDD	es:vsDataEUtranCellFDD	
CCL01736	CCL01736_7A_1	es:frameStartOffset	es:frameStartOffset	
CCL01736	CCL01736_7A_1	es:frameStartOffset	es:subFrameOffset	0
CCL01736	CCL01736_7A_1	es:frameStartOffset	es:timeOffset	0
CCL01736	CCL01736_7A_1	es:frameStartOffset	/es:frameStartOffset	
CCL01736	CCL01736_7A_1	es:systemInformationBlock6	es:systemInformationBlock6	
CCL01736	CCL01736_7A_1	es:systemInformationBlock6	es:tReselectionUtra	2
CCL01736	CCL01736_7A_1	es:systemInformationBlock6	es:tReselectionUtraSfMedium	100
CCL01736	CCL01736_7A_1	es:systemInformationBlock6	es:tReselectionUtraSfHigh	100
CCL01736	CCL01736_7A_1	es:systemInformationBlock6	/es:systemInformationBlock6	
CCL01736	CCL01736_7A_1	es:vsDataEUtranCellFDD	es:timeOffset	0

Because some data are between two tag so i want that tag name before that data and rest data are under es:vsDataEUtranCellFDD

Last edited by pareshkp; 03-19-2014 at 04:48 PM..
# 2  
I do not understand the requirements as stated. I think there is too much data included in this example. I don't see the logic by comparing the input and the output files.

The problem statement isn't clear. The provided data samples are not clear. Perhaps you should try putting a script together of some sort and post what you tried.
# 3  
1) 4th column, are you using a space or tab delimiter?
2) same name? what part or column is that?

And, what have you tried?
# 4  
4th column Space delimiter

Between This two Data i want o put that data name in third column
Example :-

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding an extra date column in UNIX file

Hi All, I have a file with only one column of data (without delimiter). For Ex: cat temp.txt 22055 21088 93840 30990 50990 50950 I want to insert an additional column with current date as value. So, i have used below command but didn't get the result as excepted. Could onyone over... (5 Replies)
Discussion started by: Suresh
5 Replies

2. Shell Programming and Scripting

Adding data from a file based on some condition

I collect data in a file in below format(Month Day Year Size) in RedHat Linux. Now i want to calculate the data size date wise. As i code shell script after long time, i forgot the features and syntax. Can anyone help me regard this please. Feb 8 2014 15 Feb 10 2014 32 Feb 10 2014 32 Feb 12... (2 Replies)
Discussion started by: makauser
2 Replies

3. Shell Programming and Scripting

Copy same name data from other file base on column

HI I have input file A.txt X Y Z File B.txt 1 X 10 AAA 11123 2 Y 22 PlD 4563 3 Z 55 PlD 54645 4 Z 66 PlD 15698 5 F 44 PlD 154798 6 C 55 PlD 12554 7 Z 88 PlD 23265 8 C 99 PlD 151654 9 C 11 PlD 21546546 I need New File C.txt (1 Reply)
Discussion started by: pareshkp
1 Replies

4. Shell Programming and Scripting

Need help in column comparison & adding extra line to files

Hi, I wanted to check whether the x,y,z coordinates of two files are equal or not. At times, when one file is converted to another suitable file extension , there are some chances that the data mismatch would happen during the conversion. In order to avoid the data misfit, i would like to... (6 Replies)
Discussion started by: b@l@ji
6 Replies

5. Shell Programming and Scripting

Adding Extra Commas to a CSV file

Trying in this forum. Not sure if it is permitted.... but in need of help. Please find the requirements in the below link. Thanks in Advance. (1 Reply)
Discussion started by: chillblue
1 Replies

6. Shell Programming and Scripting

how to add extra a field in a flat txt file ?

Hi all, I did not use UNIX for a long time, now i need to make a flat file with extra field, can you help me with the code ? 1. I create a last line of each log from each system and make it in a flat text file (seperate by a pipe |) mv current.log old tail -1 sanfrancisco.log > current.log... (5 Replies)
Discussion started by: britney
5 Replies

7. AIX

Adding column in a .txt file

Helle, I want to create a .ksh script in order to realize the following : I have a .txt file organized in a bloc of information, each bloc start with 000 as following: 000... 001... 003... 004... 000... 001... 003... 004... . . My aim is to add a new... (6 Replies)
Discussion started by: zainab2006
6 Replies

8. Shell Programming and Scripting

sort file adding extra character

HI all i have this script : #!/bin/bash sort /usr/tmp/"REPORT"$1 -o \ /usr/tmp/"SREPORT"$1 -k 1,7 -S 150 end of script now i'm doing this command : ls -lsgt *REPORT* 4 -rw-r--r-- 300 Sep 16 REPORT54784 4 -rw-r--r-- 301 Sep 16 SREPORT54784 as you can see the sorted file... (5 Replies)
Discussion started by: naamas03
5 Replies

9. UNIX for Dummies Questions & Answers

Adding EMPTY columns to Tab-delimited txt file

Hi I have a txt file with 4 columns where I need to add 4 empty columns in the middle meaning that I need what is currently column 4 to be column 8 in a new file. The idea is that I have to use the file as input in a program that reads the data in column 1 and 8, so the content of the other... (8 Replies)
Discussion started by: Banni
8 Replies

10. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

Featured Tech Videos