Change Data of first ROW


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change Data of first ROW
# 1  
Old 11-05-2015
Display Change Data of first ROW

My Input :

A.txt

Code:
1@A	2@B	3@C
1	4	5
2	4	5
3	4	5

B.txt

Code:
1	2	3
A	B	C
1	4	5
2	4	5
3	4	5

# 2  
Old 11-05-2015
Hello asavaliya,

Could you please try following and let me know if this helps.
Code:
awk 'NR==1{for(i=1;i<=NF;i++){split($i, A,"@");B=B?B OFS A[1]:A[1];C=C?C OFS A[2]:A[2]};print B ORS C;next} {print}' OFS="\t" Input_file

Output will be as follows.
Code:
1	2	3
A	B	C
1	4	5
2	4	5
3	4	5

NOTE: Above will check the first line and considering that it has only @ within letters then it should work.

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 11-05-2015
Perfect !!!!!
# 4  
Old 11-05-2015
Try also
Code:
awk '
NR==1           {T=$0
                 gsub (/@[^\t]*/, "")
                 print
                 $0=T
                 gsub (/[^\t]*@/, "")
                }
1
' file
1    2    3
A    B    C
1    4    5
2    4    5
3    4    5

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to change row by order nr?

Hello, I have a file with thousands of rows and I need to change sequence of lines. Sample file: #NAME #SERVICE 112233 #DESCRIPTION AABBCCDD #SERVICE 738292 #DESCRIPTION FFYYRRTT ... ... ... Desired output: #NAME (5 Replies)
Discussion started by: baris35
5 Replies

2. Shell Programming and Scripting

Change to row

var="abc || ddfdfd fdfd || xxxx||" to abc ddfdfd fdfd xxxx (2 Replies)
Discussion started by: yanglei_fage
2 Replies

3. Emergency UNIX and Linux Support

[Solved] Mysql - Take data from row and copy it to another row

Sorry if I repost my question in this section, but I'm really in a hurry since I have to finish my work... :( Dear community, I have a table with two rows like: Row1 Row2 ======= ======= 7,3 text 1 1,3 text 2 1,2,3 blabla What i need to do is add/copy... (2 Replies)
Discussion started by: Lord Spectre
2 Replies

4. UNIX for Advanced & Expert Users

Convert column data to row data using shell script

Hi, I want to convert a 3-column data to 3-row data using shell script. Any suggestion in this regard is highly appreciated. Thanks. (4 Replies)
Discussion started by: sktkpl
4 Replies

5. Shell Programming and Scripting

Convert row data to column data

Hi Guys, I have a file as follows: a 1 b 786 c 90709 d 99 a 9875 b 989 c 887 d 111 I want: a 1 9875 b 786 989 (3 Replies)
Discussion started by: npatwardhan
3 Replies

6. Shell Programming and Scripting

How to change a file's content by row?

Greetings. So the question is basically the same as it's in the title. I'd like to write a program that changes a file by rows. So to clarify it. (i know i shouldn't use code,/code here but i would like to separate it) So for example a text file looks like something like this: Happy... (5 Replies)
Discussion started by: buddhist
5 Replies

7. Shell Programming and Scripting

Add value of each row when each row has different data ype

Guys -- I am noob and I am really strugging on this one. I cant even write the pseudo code for it. I have a file that spits values in individual rows as such: file: user date type size joe 2005-25-09 log 1 joe 2005-25-09 snd 10 joe 2005-25-09 rcd 12 joe 2005-24-09 log 2 joe... (1 Reply)
Discussion started by: made2last
1 Replies

8. Shell Programming and Scripting

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies

9. Shell Programming and Scripting

how to change row into columns

hi, I have a input file like a,123,456,789,012,.......,b I need to change the output file into a,123,b a,456,b a,789,b a,012,b a,...,b like that.. how to achieve that through UNIX................. (5 Replies)
Discussion started by: aaha_naga
5 Replies
Login or Register to Ask a Question