Hello,
I have for instance these 2 files :
file1
1
2
3
file2
4
5
6
Can I with join command have an output file3 like :
1 4
2 5
3 6
Thx in advance for help,
Hello,
I have for instance these 2 files :
file1
1
2
3
file2
4
5
6
Can I with join command have an output file3 like :
1 4
2 5
3 6
Thx in advance for help,
Something like this should solve what you described (this sample uses two input files A.txt and B.txt)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #!/bin/bash awk ' BEGIN { # load array with contens f1.txt while ( getline < "A.txt" > 0 ) { f1_counter++ f1[f1_counter] = $1 } } { # print $1 " " f1[NR] } ' B.txt
Thx for the reply.
But I want to see if it is possible to do it with join command and it is options maybe.
Do you have an idea about it ?
for join command you need a common field present on both file
basically join will give you this
options of join will provide some tweak about field separators, key to use in both files, or formatting the output.file1
1 A
2 B
3 C
file 2
1 E
2 F
3 G
join file1 file2
AE
BF
GC
you will fine an explanation on how this work here
http://www.softpanorama.org/Tools/join.shtml
An other unix command provides what you want.
This is the paste command.
http://unixhelp.ed.ac.uk/CGI/man-cgi?paste
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 sh-3.1$ cat A.txt 1 1 2 2 3 3 sh-3.1$ cat B.txt 1 A 2 B 3 C sh-3.1$ paste A.txt B.txt 1 1 1 A 2 2 2 B 3 3 3 C
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager