repeated column data filter and make as a row


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting repeated column data filter and make as a row
# 1  
Old 06-16-2009
repeated column data filter and make as a row

I need to get the output in row wise for the repeated column data

Ex:
Input:


que = five
ans = 5

que = six
ans = 6


Required output:

que = five six
ans = 5 6


Any body can guide me?""""""
# 2  
Old 06-16-2009
Code:
awk -F"=" '{ a[$1]=a[$1]" "$2;next}END { for(i in a) print i "  " a[i] }'  input.txt

# 3  
Old 06-16-2009
echo "Que = `grep "que" s | cut -d"=" -f2 | xargs`"
echo "Ans = `grep "ans" s | cut -d"=" -f2 | xargs`"

-----Post Update-----

"s" is the filename

-----Post Update-----

"s" is the filename
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter Row Based On Max Column Value After Group BY

Hello Team, Need your expertise on following: Here is the set of data: C1|4|C1SP1|A1|C1BP1|T1 C1|4|C1SP2|A1|C1BP2|T2 C2|3|C2SP1|A2|C2BP1|T2 C3|3|C3SP1|A3|C3BP1|T2 C2|2|C2SP2|A2|C2BP2|T1 I need to filter above date base on following two steps: 1. Group them by column 1 and 4 2.... (12 Replies)
Discussion started by: angshuman
12 Replies

2. Shell Programming and Scripting

Column to Row Data.

HI Guys, I have below Input :- X L1 5 Y L1 10 Z L1 15 X L2 20 Y L2 12 Z L2 15 X L3 100 Y L3 Z L3 300 Output:- ID L1 L2 L3 X 5 10 15 Y 20 12 15 Z 100 Null 300 (11 Replies)
Discussion started by: pareshkp
11 Replies

3. Shell Programming and Scripting

Replace First Column and First Row Data

HI Guys, I just want to replace data for First Column and Row Cell(1,1) Input :- Hello A B C X 1 2 3 Y 4 5 6 Z 7 8 9 Output:- Byee A B C X 1 2 3 Y 4 5 6 Z 7 8 9 From Hello to Byee .....And The Each file have Different String. (3 Replies)
Discussion started by: pareshkp
3 Replies

4. Shell Programming and Scripting

Filter more data in single column

Hi All, One of my source file column name RelationshipNumber. I need to filter below mentioned records in RelationshipNumber column. RelationshipNumber: S45678 D89763 Y09246579 A91234 If it is available in above mentioned column, then I need to print the entire line from my source... (2 Replies)
Discussion started by: suresh_target
2 Replies

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

6. Shell Programming and Scripting

Moving data from a specified column/row to another column/row

Hello, I have an input file like the following: 11_3_4 2_1_35 3_15__ _16989 Where '_' is a space. The data is in a table. Is there a way for the program to prompt the user for x1,y1 and x2,y2, where x1,y1 is the desired number (for example x=6 y=4 is a value of 4) and move to a desired spot... (2 Replies)
Discussion started by: jl487
2 Replies

7. Shell Programming and Scripting

Filter and migrate data from row to column

Hello Experts, I am new in scripting. I would like to filter and migrate data from row to column by awk. Thanks in advance. For example FileA abc 1 2 3 Xyz3 4 1 5 bcd1 Output : Abc 1 2 3 Xyz3 4 1 5 bcd1 3 5 6 (5 Replies)
Discussion started by: shah09
5 Replies

8. Shell Programming and Scripting

row to column and position data in to fixed column width

Dear friends, Below is my program and current output. I wish to have 3 or 4 column output in order to accomodate in single page. i do have subsequent command to process after user enter the number. Program COUNT=1 for MYDIR in `ls /` do VOBS=${MYDIR} echo "${COUNT}. ${MYDIR}" ... (4 Replies)
Discussion started by: baluchen
4 Replies

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

10. Shell Programming and Scripting

Script - Filter data - repeated loop - Help needed...

Dear Friend, I need a help for the below problem.. Can anyone suggest me to do... Input file data: rule { name=mainrule filt=pos loc { x=right + 660 y=top - 3100 } object_kind= DRAW ... (15 Replies)
Discussion started by: vasanth_vadalur
15 Replies
Login or Register to Ask a Question