Sponsored Content
Top Forums Shell Programming and Scripting Adding Extra Column in txt file base on Condition Post 302893520 by pareshkp on Wednesday 19th of March 2014 03:09:14 PM
Old 03-19-2014
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
Code:
Input:-				
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	
				
Output:-				
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..
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

6. 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. https://www.unix.com/unix-dummies-questions-answers/191503-add-extra-commas-csv-file-2.html#post302665179 Thanks in Advance. (1 Reply)
Discussion started by: chillblue
1 Replies

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

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

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

10. 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
PPIx::Regexp::Token::Condition(3)			User Contributed Perl Documentation			 PPIx::Regexp::Token::Condition(3)

NAME
PPIx::Regexp::Token::Condition - Represent the condition of a switch SYNOPSIS
use PPIx::Regexp::Dumper; PPIx::Regexp::Dumper->new( 'qr{(?(1)foo|bar)}smx' ) ->print(); INHERITANCE
"PPIx::Regexp::Token::Condition" is a PPIx::Regexp::Token::Reference. "PPIx::Regexp::Token::Condition" has no descendants. DESCRIPTION
This class represents the condition portion of a switch or conditional expression, provided that condition is reasonably represented as a token. METHODS
This class provides no public methods beyond those provided by its superclass. SUPPORT
Support is by the author. Please file bug reports at <http://rt.cpan.org>, or in electronic mail to the author. AUTHOR
Thomas R. Wyant, III wyant at cpan dot org COPYRIGHT AND LICENSE
Copyright (C) 2009-2013 by Thomas R. Wyant, III This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. perl v5.16.3 2014-06-10 PPIx::Regexp::Token::Condition(3)
All times are GMT -4. The time now is 06:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy