hi,
i have probleme to extract the columns info from file to another one;
FILE A look like :
x,inof1
y,inof1
z,info2
t,inof3
and FILE B like
x
t
w
d
z
i want to add correpondant columns (info) to each line of FILE B and sort this file by this columns.
lines in FILEA and B are not sorted .
thanks
what is the final result based on the sample files given above?
the final result is FILE B:
x,info1
t,info3
w infox
d infoxx
z info2
and after sort:
FILE B
x,info1
z info2
t,info3
w infox
d infoxx
that depends of infox and infoxx cause i have many lines in this file
thanks
Use "paste" and "sort -u" command
infox or info1 are alphanumeric also x,y,z ...
i use abreviation for line cause i want to print the the line "line" in the correspondant line .
the line x y z are the same in two files there is no comma in the two file only space betwen linex , y or z and line info.
i can't use paste cause the FILEB and FILEA are not sorted.
thankx
kamel.seg:
infox or info1 are alphanumeric also x,y,z ...
i use abreviation for line cause i want to print the the line "line" in the correspondant line .
the line x y z are the same in two files there is no comma in the two file only space betwen linex , y or z and line info.
i can't use paste cause the FILEB and FILEA are not sorted.
thankx
What about sorting those files and then merging them on the similar column(s) using the paste command? Is there a reason why you choose not to use sort?
hi,
i can't use paste because in the FILEB there's more line then FILEA so if i sort the two file and do paste i will not get the result.
can u help me to loop this problem with shell script to paste every info in each correspond line and after that i sort this file by columns (info columns).
thanks
Well can you show a sample of the contents of fileA and fileB?
Sample of FILEA :
comp, PASS
sim, FAILED
UF, PASS
promo, FAILED
xy, PASS
bad, PASS
bad_12, PASS
bridge_AD, FAILED
sim_V3 PASS
split_LSF, PASS
multiple, FAILED
and FILEB
comp, PASS
sim, test_sim
UF, data_uf
promo, data_uf
bad, test_bad
split_LSF, groupe_lsf
multiple, groupe_test
thanks
kamel.seg:
Sample of FILEA :
comp, PASS
sim, FAILED
UF, PASS
promo, FAILED
xy, PASS
bad, PASS
bad_12, PASS
bridge_AD, FAILED
sim_V3 PASS
split_LSF, PASS
multiple, FAILED
and FILEB
comp, PASS
sim, test_sim
UF, data_uf
promo, data_uf
bad, test_bad
split_LSF, groupe_lsf
multiple, groupe_test
thanks
And what is the expected output based on the sample contents of fileA and fileB?
Sample of FILEA :
comp, PASS
sim, FAILED
UF, PASS
promo, FAILED
xy, PASS
bad, PASS
bad_12, PASS
bridge_AD, FAILED
sim_V3 PASS
split_LSF, PASS
multiple, FAILED
and FILEB
comp, groupe1
sim, test_sim
UF, data_uf
promo, data_uf
bad, test_bad
split_LSF, groupe_lsf
multiple, groupe_test
the excepted output is
FILEA:
comp, groupe1
sim, FAILED test_sim
UF, PASS data_uf
promo, FAILED data_uf
xy, PASS test_bad
bad, PASS
bad_12, PASS
bridge_AD, FAILED
sim_V3 PASS
split_LSF, PASS groupe_lsf
multiple, FAILED groupe_test
thanks
kamel.seg:
Sample of FILEA :
comp, PASS
sim, FAILED
UF, PASS
promo, FAILED
xy, PASS
bad, PASS
bad_12, PASS
bridge_AD, FAILED
sim_V3 PASS
split_LSF, PASS
multiple, FAILED
and FILEB
comp, groupe1
sim, test_sim
UF, data_uf
promo, data_uf
bad, test_bad
split_LSF, groupe_lsf
multiple, groupe_test
the excepted output is
FILEA:
comp, groupe1
sim, FAILED test_sim
UF, PASS data_uf
promo, FAILED data_uf
xy, PASS test_bad
bad, PASS
bad_12, PASS
bridge_AD, FAILED
sim_V3 PASS
split_LSF, PASS groupe_lsf
multiple, FAILED groupe_test
thanks
sort -t"," -k1,1 fileA > FILEA
sort -t"," -k1,1 fileB > FILEB
join -t"," -1 1 -2 1 -a 1 -o 1.1 1.2 2.2 FILEA FILEB > output.txt