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
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 07:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy