Data Manipulation

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Data Manipulation
# 1  
Old 02-12-2014
Data Manipulation

Dear Sir,

I have file input


I want to create files by joining each rows with each rows below

Output as below


Big Thanks
# 2  
Old 02-12-2014
So a few questions:-
  • What have you tried so far?
  • What output or errors are you getting?
  • What OS and version are you using?
  • What are your preferred tools?
  • Can you explain the problem a little better? To join every row to every row, you should get either 16 lines of output or at the least 12, or do you mean unique combinations (any part first) when you would give you 6 rows.
  • Can you reduce your input to just:-

    .... and show us the expected output?

Most importantly, what have you tried so far?

I have a few ideas, but it would be better for you to have a good try and we can suggest adjustments. That way you get your logic right & learn the skills you need, and others get a good discussion.


Last edited by rbatte1; 02-12-2014 at 08:59 AM.. Reason: Line spacing
# 3  
Old 02-13-2014
Mr Robin, for 4 rows my output should be

since my data is row-n, so sum of join pattern around nC2 (combination factor)

I did this

awk '!f{a=$0;f=1;next}{printf("%s | %s\n", a, $0); f=0}' file

but it only compares row 1 to row 2, row 3 to row 4 and so on..
I need to compare all rows
# 4  
Old 02-13-2014
awk -F\| '
                A[NR] = $0
        END {
                for ( i = 1; i <= NR; i++ )
                        j = i + 1
                        while ( j <= NR )
                                print A[i] FS A[j]
                                j += 1
' file

# 5  
Old 02-13-2014
Try :
$ awk 'FNR==NR{A[NR]=$0;c=NR;next}{for(i=FNR+1;i<=c;i++)print $0,A[i]}' OFS=\| file{,}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Data manipulation, Please help..

Hello, I have a huge set of data that needs to be reformatted. Here is a simple example to explain the process. I have number n=5 and a input with many numbers separated with comma: ... (11 Replies)
Discussion started by: liuzhencc
11 Replies

2. Shell Programming and Scripting

[Solved] Data manipulation

Hallo Team, I need your help. I have a file that has two colums. See sample below: 105550 0.28 105550 0.24 125550 0.28 125550 0.24 215650 0.28 215650 0.24 315550 0.28 315550 0.24 335550 0.28 335550 0.24 40555 0.21 40555 0.17 415550 0.21 415550 0.17 43555 0.21 43555 0.17 (5 Replies)
Discussion started by: kekanap
5 Replies

3. UNIX for Dummies Questions & Answers

Data manipulation

Hallo Team, I need to manipulate existing data file. Have a look at current data and expected data: Current Data: 27873517141 27873540000 27873515109 27873517140 27873540001 27873540000 27873501343 27873540000 27873517140 27873511292 27873645989 27873540000 27873540000... (7 Replies)
Discussion started by: kekanap
7 Replies

4. Shell Programming and Scripting

Data manipulation using shell

Dear all I have a dataset (in text format,delimited by tab) which have 100 variables (say, var0-var99) and more than 100,000 observations. I want to do the following: 1. for variable var0-var49, I want to add "00" in front of each data (for example, "1" would become "001") 2. for variable... (8 Replies)
Discussion started by: littlewenwen
8 Replies

5. Shell Programming and Scripting

Help with data manipulation script

Y,T,,H05,6,6,0,0 -> TH05_6 D,5,BT,B -> BT_KIOSK P,KQC222 -> KQC222 G,B,2 -> BRANI_GATE_2 fileA TPM658 Y,T,,H05,6,6,0,0 TPM110 D,5,BT,B TPM136 P,KQC222 TPM180 P,BQC913 TPM575 Y,B,,T05,14,14,0,0 IPM760 G,B,2 TPM011 I need to use second column $1,$2,$3,$4..... if first char... (6 Replies)
Discussion started by: ment0smintz
6 Replies

6. UNIX for Dummies Questions & Answers

Script for data manipulation

Hi all! my first post here, so mods -- if this should ideally be in the scripts section, please move there. Thanks! I have data in the following format: key1:value1 key2:value2 key3:value3 A B C D key1:value4 key2:value5 key3:value6 A1 B1 key1: ... and so on I want an output... (2 Replies)
Discussion started by: gnat01
2 Replies

7. Shell Programming and Scripting

Data manipulation from a file

i have a file in follwing format 0110 1020 1011 1032 1020 2005 2003 1050 i want the output in such a way that all non zero numbers will be converted into 1 like this 0110 1010 1011 1011 1010 1001 1001 1010 (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

8. Shell Programming and Scripting

Tricky data manipulation...

Hi everyone.. I am new here, hello.. I hope this doesn't come across to you folks as a stupid question, I'm somewhat new to scripting :) I'm seeking some help in finding a way to manipulate data output for every two characters - example: numbers.lst contains the following output:... (3 Replies)
Discussion started by: explicit
3 Replies

9. UNIX for Dummies Questions & Answers

Data Manipulation

Hello I am currently having problems in mapulating a certain file which contains vaious data. Belos is a sample content Event=<3190> Client IP=<> DNS=<> TransCount=<139> Client IP=<> DNS=<> TransCount=<3734> Event=<3120> Client... (11 Replies)
Discussion started by: khestoi
11 Replies

10. UNIX for Dummies Questions & Answers

data manipulation script

I have a folder called {homedata} Within this folder there are 12 subfolders 200601.......200612 Within each subfolder there are 8 sets of files Each filename commences with A B C D E F G or H, so {filename}* can be used. I am trying to write a script which will from the top level go... (1 Reply)
Discussion started by: grinder182533
1 Replies
Login or Register to Ask a Question